i have p:accordionpanel represents list of items , in each tab there form. upon submitting of repeating forms, possible data in needed, when p:dialog popped prompting user enter more data. dialog defined outside accordion panel because, unlike items accordion, 1 of them can showing @ time there no need augment html served repeating in each tab of accordion.
the definition of accordion looks follows (simplified relevant descriptors):
<p:accordionpanel id="myaccordion" value="#{managedbean.getaccordionlist}" var="item" multiple="false" dynamic="true" cache="true"> <p:ajax event="tabchange" listener="#{managedbean.processtabchange}"/> <p:tab title="#{item.tabtitle}" id="itemtab"> <h:form id="itemform"> <h:outputlabel for="itemname" value="item name:"/> <p:inputtext id="itemname" title="item name:" maxlength="16" value="#{appeal.itemname}"> </p:inputtext> consequently, html rendered itemname myaccordion:0:itemform:itemname in first instance, myaccordion:1:itemform:itemname in second, etc.
the dialog defined follows:
<p:dialog id="commentdialogid" header="enter comment" widgetvar="commentdialog" modal="true" resizable="true" height="auto"> <h:form id="commentform"> <h:outputlabel for="comment" value="comment:"/> <p:inputtextarea id="comment" title="comment" rows="6" cols="33" value="#{managedbean.activeitem.comment}" required="true"> <f:ajax render="comment"/> </p:inputtextarea> <h:commandbutton value="submit" action="#{managedbean.proceed}" onclick="pf('commentdialog').hide();"> <f:ajax render="*** ??? ***"/> </h:commandbutton> </h:form> </p:dialog> what have repeatedly been failing @ attempts f:ajax update single tab in accordion panel, active 1 dialog popped up. tried using
:myaccordion:#{managedbean.activeitem.displayindex}:itemform:itemname :myaccordion:#{managedbean.activeitem.displayindex}:itemform :myaccordion:#{managedbean.activeitem.displayindex}:itemtab in place of *** ??? *** none of them compile:
javax.faces.facesexception: <f:ajax> contains unknown id ':myaccordion:0:itemform' - cannot locate in context of component j_idt20 if skip index token (e.g. :myaccordion:itemform:itemname) compile functionally nothing. item entity class has getdisplayindex accurately return index of active tab.
my problem quite similar described in this question, doesn't have answer. limitation of primefaces?
i don't know version of primefaces using, seems bug in primefaces 5.1.1 recreate issue. upgrading primefaces 5.2, ajax el find referenced id. can post mcve if needed.
edit: mcve:
xhtml:
<h:form id="itemform"> <p:accordionpanel id="myaccordion" binding="#{accordionview}" value="#{playgroundcontroller.users}" dynamic="true" activeindex="#{playgroundview.activeindex}" var="user" multiple="false"> <p:ajax event="tabchange" update="commentdialogid"/> <p:tab title="#{user.name}"> <h:outputlabel for="itemname" value="item name:" /> <p:inputtext id="itemname" title="item name:" maxlength="16" value="#{user.amount}"> </p:inputtext> <p:commandbutton value="showdialog" onclick="pf('commentdialog').show();"></p:commandbutton> </p:tab> </p:accordionpanel> </h:form> <p:dialog id="commentdialogid" header="enter comment" widgetvar="commentdialog" modal="true" resizable="true" height="auto"> <h:form id="commentform"> <h:outputlabel for="comment" value="comment:"/> <p:inputtextarea id="comment" title="comment" rows="6" cols="33" value="#{playgroundview.activeindex}" required="true"> <f:ajax render="comment"/> </p:inputtextarea> <p:commandbutton value="submit" onclick="pf('commentdialog').hide();" update=":itemform:myaccordion:#{playgroundview.activeindex}:itemname" ></p:commandbutton> </h:form> </p:dialog> playgroundview bean:
note in example activeindex has have initial value, otherwise el:
update=":itemform:myaccordion:#{playgroundview.activeindex}:itemname" will resolve wrongly , throw error cannot find id of referenced component. of course has drawback first tab open when page loads, that's issue
private string activeindex = "0"; public string getactiveindex() { return activeindex; } public void setactiveindex(string activeindex) { this.activeindex = activeindex; } playgroundcontroller bean:
private list<user> users; @override public void initializeview() { createusers(); } public void createusers() { user user1 = new user(); user user2 = new user(); user user3 = new user(); user1.setname("user123"); user1.setamount(1); user2.setname("user456"); user2.setamount(2); user3.setname("user12312345111111111111111111111111111"); user3.setamount(3); list<user> userlist = new arraylist<user>(); userlist.add(user1); userlist.add(user2); userlist.add(user3); users = userlist; } user:
public class user implements serializable { string name; int amount = 0; }
Comments
Post a Comment