3

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:

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
Community
  • 1
  • 1
julianobrasil
  • 8,954
  • 2
  • 33
  • 55
  • _" (and I found a lot of questions like mine, but none could solve my problem)."_ See [ask]. Post which questions and why they did not solve it for you – Kukeltje Aug 16 '16 at 12:38
  • @Kukeltje, I`ve edited the question and pasted some of the links I've tried. – julianobrasil Aug 16 '16 at 14:29

0 Answers0