F: ajax inside ui: repeat, unknown component id

When I try to display the Panel group when calling ajax, it gives an unknown identifier.

<h:form id="form1" prependId=false> <h:panelGroup id="panel1"> <h:dataTable/> <ui:repeat value="#{bean.page}" var="page"> <h:commandLink value="#{page}"> <f:ajax execute="@form" render="panel1" listener="#{bean.page}" /> </h:commandLink> </ui:repeat> </h:panelGroup> </h:form> 

When I tried this code, it gives an unknown id1 panel. I tried with id ": panel1" too. I get the same error.

+6
source share
2 answers

The relative client identifier (i.e., not starting with : refers to the current parent component of NamingContainer . <ui:repeat> also a NamingContainer . Thus, render="panel1" looks for the component in the context of <ui:repeat> . This will not work. The absolute client identifier (i.e., Starting with : searches for the component in the context of the view root. But you have inside <h:form> , which in turn is another component of the NamingContainer , so render=":panel" will not work either.

The following should work with prependId="false" remote so you can reference it:

 <h:form id="form1"> <h:panelGroup id="panel1"> <h:dataTable/> <ui:repeat value="#{bean.page}" var="page"> <h:commandLink value="#{page}"> <f:ajax execute="@form" render=":form1:panel1" listener="#{bean.page}" /> </h:commandLink> </ui:repeat> </h:panelGroup> </h:form> 

By the way, if you really want to display only the table, then you should do this:

 <h:form id="form1"> <h:panelGroup> <h:dataTable id="table1" /> <ui:repeat value="#{bean.page}" var="page"> <h:commandLink value="#{page}"> <f:ajax execute="@form" render=":form1:table1" listener="#{bean.page}" /> </h:commandLink> </ui:repeat> </h:panelGroup> </h:form> 

Update : according to the comments, it turns out that you changed the default separator character of the NamingContainer JSF from : to _ by configuration. In this case, you need to use _ instead of : in the client identifier selector.

 <f:ajax execute="@form" render="_form1_panel1" listener="#{bean.page}" /> 
+19
source
 <ui:repeat value="#{interaction.interactionListBean}" var="interactionItr"> <h:commandLink value="#{interactionItr.interactionDate}" styleClass="#{interaction.createImage}" style="margin:0 5px 5px 0!important; display:inline-block;"><br/> <f:ajax render=":formId:interactionDate :formId:category :formId:activity :formId:status :formId:channel :formId:status1 :formId:caseId :formId:comment :formId:user1 :formId:team :formId:user :formId:transit " listener="#{interactionController.interactionDetailGet}"/> <f:param name="RefId" value="#{interaction.interactionRefId}"/> </h:commandLink> </ui:repeat> 

problem: see above with the code above, they are not an exception on the console, but ajax listerner will not be referenced when I see that this message looks like a concept using only that I used exceute = "@form", then my encoding is working fine

decision:

execute="@form"

0
source

Source: https://habr.com/ru/post/895220/


All Articles