Ajax not calling listener, opening modal panel anyway.
arnieaustin Oct 31, 2015 2:17 PMI have a bean that displays a list of records on a tab page in a data grid. The last column, Action, contains a rich:dropDownMenu with two actions: Edit and View.
The menus are supposed to execute a method on the list's bean to prepare a variable that will be used by the modal panel's bean to configure itself and read the requisite data; only they are never called and modal panel always appears. So, using another example from here, I altered their construct below. (Note: the okToOpen variable is set elsewhere in the class to false.)
<rich:dropDownMenu label="#{messages.getString('application.lbl.cmdHover')}" > <rich:menuItem id="menuInfoPersonCommentEdit" actionListener="#{infoPersonCommentList.editListener}" execute="@this" mode="ajax" data="#{infoPersonCommentList.okToOpen}" oncomplete="if (event.data) { #{rich:component('modalInfoPersonCommentEdit')}.show(); } else { alert('not ok to open'); } " label="#{messages.getString('application.lbl.linkEdit')}" render="panelModalInfoPersonCommentEdit" > <f:param name="cid" value="#{javax.enterprise.context.conversation.id}" /> </rich:menuItem> <rich:menuItem id="menuInfoPersonCommentView" actionListener="#{infoPersonCommentList.viewListener}" execute="@this" mode="ajax" label="#{messages.getString('application.lbl.linkView')}" data="#{infoPersonCommentList.okToOpen}" oncomplete="if (event.data) { #{rich:component('modalInfoPersonCommentEdit')}.show(); } else { alert('not ok to open'); } " render="panelModalInfoPersonCommentEdit" > <f:param name="cid" value="#{javax.enterprise.context.conversation.id}" /> </rich:menuItem> </rich:dropDownMenu>
So now, all I get is the alert, and no logging from the bean that it was called (break points confirm no calls). The bean methods are pretty simple:
public void editListener(ActionEvent event) { okToOpen = false; InfoPersonCommentDTO dto = getDataModel().getRowData(); if ( dto != null ) { infoPersonCommentDTOEdit.setBaseActionPageModeEnum(BaseActionPageModeEnum.EDIT); infoPersonCommentDTOEdit.setObjectId(dto.getId()); infoPersonCommentDTOEdit.setReadOnly(Boolean.FALSE); infoPersonCommentDTOEdit.setDoResetForWork(Boolean.TRUE); okToOpen = true; } }
The values in infoPersonCommentDTOEdit are then produced (CDI) from this bean for injection into the bean that manages the modal panel, which isn't called either when the modal panel opens.
Which bring up the next topic which -may- be related. I want the focus put into a field when the modal panel opens and in order to initialize the panel, I use an f:event on the preRenderView method of the modal panel bean to trigger the initialization. This kind of set up works fine with page A to page B event handling using h:commandButtons and JSF navigations. But things just aren't happening when ajax gets enabled and I have no idea why.