I know it seems like a duplicate question (and I found a lot of questions like mine, but none could solve my problem). In fact, as long as it can be a lack of attention of mine, yes it can be a duplicate. Here it is: I have two updates not working well: the most important is one, concerning a button inside a composite component (a p:dialog with its own h:form inside) trying to update a p:autoComplete in another h:form. The composite also receive a listener as a parameter and, in the listener, it updates a property of the bean: this is one of the problems - this property is bound to the value attribute of the p:autoComplete and I was not able to update it after the listener change its value.
The other problem is a p:inputReset which is apparently doing nothing (it should clear up the input fields in the same composite above).
I've already checked out the updates attributes values with the browser development tool, and they're correct.
One more information: the problem started after I put the dialog inside a composite. It used to work fine before it.
[EDITED]: These are some of the topics I've researched:
- How to update a composite component form from another composite component?: The composite component already had an update attribute in the cc:interface section and it's not helping with this problem. @stg said it's a bad design to put a form inside a composite component, but would it prevent it from updating other components? [EDITED 2]: Anyway, I moved the form out of the composite (and moved the component into a form). The problem remains.
- How to find out client ID of component for ajax update/render? Cannot find component with expression “foo” referenced from “bar”: Very detailed @BalusC answer. I already checked the paths to the component being updated and they seem to be correct (actually, cc.parent.namingContainer.clientId and other syntactic sugar is not getting the clientId, maybe some of them are deprecated - the answer was wrote in 2011). Anyway, all the working approaches pointed there result in the same path I put in the example bellow.
- Updating a component outside of the component's context: I've tried with and without the leading ":". Made no difference.
There are other questions about this topic all over the Internet, but they are variations of this problem and most of them could be solved with the same things pointed by @BalusC in the link above.
In my case the behavior occured in a structure like this (simplified):
A template:
...
<h:body>
<h:form id="dlgTemplateForm">
<p:tabView id="tbvMain">
<ui:insert name="tabs" />
</p:tabView>
</h:form>
<ui:insert name="outsideDlgTemplateForm" />
</h:body>
I also have a composite component (dlgComp.xhtml) that looks like:
<cc:interface>
<cc:attribute name="returnListener" method-signature="void listener()" />
<cc:attribute name="bean" type="com.foo.BeanClass" />
<cc:attribute name="widgetVar" />
<cc:attribute name="update" />
</cc:interface>
<cc:implementation>
<div id="#{cc.clientId}">
<p:dialog id="dlg" widgetVar="#{cc.attrs.widgetVar}">
<h:form id="dlgForm">
<p:inputText id="ipm" value="#{cc.attrs.bean.obj}" />
<!--here is the componentn with the update which doesn't work-->
<p:commandButton id="btnSave"
actionListener="#{cc.attrs.returnListener}"
value="Gravar"
update="#{cc.attrs.update}"
oncomplete="PF('#{cc.attrs.widgetVar}').hide()"/>
</h:form>
</p:dialog>
</div>
</cc:implementation>
Then, I build myPage.xhtml, based on the template above. Inside it:
<ui:define name="tabs">
<p:tab id="tabInfo">
<ui:include src="myTab.xhtml" />
</p:tab>
</ui:define>
<ui:define name="outsideDlgTemplateForm">
<myComp:dlgComp id="dlgId"
widgetVar="dlgIdWGV" bean="#{myPageBean.myPageManagedProperty}"
returnListener="#{myPageBean.returnFromDialog}"
update=":dlgTemplateForm:tbvMain:acpTest" />
</ui:define>
In myTab.xhmtl (to be included in myPage.xhtml), I have this:
<p:autoComplete id="acpTest" value="#{myPageBean.prop}"
completeMethod="#{myPageBean.acpCompleteText}" />
<p:commandButton actionListener="#{myPage.listener}"
oncomplete="PF('dlgIdWGV').show();"
update=":dlgId:dlgForm" process="@this">
<p:resetInput target=":dlgId:dlgForm" /> <!--this doesn't work too-->
</p:commandButton>
In myPageBean.java
@ManagedProperty(value = "beanClass")
private com.foo.BeanClass myPageManagedProperty;
private Object prop;
//getters and setters
public void returnFromDialog(void) {
this.prop = myPageManagedProperty.getObj();
}
And, finally, in com.foo.BeanClass
private Object obj;
//getter and setter