I have two tabs, one tab is a list of records, clicking on a record switches to the "Edit" tab, and on the "Edit" tab - "Save" and "Cancel" buttons.
Now I click on record No. 1, make some changes and click on the "Cancel" button. Of course, I do not want to validate the form because it is canceled, so I set immediate="true" to the "Cancel" button. Now the editing tab is closed, back to the list of entries. Then I click on another record No. 2, there was a problem: on the editing tab, it is still the previous contents of record No. 1, and not record No. 2. I checked the variables in debug mode, the inverse of the bean for the edit form was ACTUALLY populated with record # 2.
Ie, something is broken after an immediate command.
(Everything was long before I added confirmation and immediately = "true".)
class FormBean { Record activeRecord; ... public void clickOnList() { activeRecord = loadRecord(clickIndex); } public void cancelForm() { activeRecord = null; } }
page.xhtml:
<h:form id="main"> ... <p:tab title="Edit" rendered="#{formBean.activeRecord != null}"> ... <p:commandButton value="Cancel" actionListener="#{formBean.cancelForm}" update="main" async="true" immediate="true" /> </p:tab> </h:form>
source share