0

I have in my facelet .xhtml multiple dialogs with forms, each dialog with multiple types input.

I want to update all inputs for specific dialog when bean property is changed (specially when bean is set to new... propertyDTO = new PropertyDTO();)

Then all property of propertyDTO must be cleared!!!

Here my View of one dialog...

<p:dialog header="Package Services" widgetVar="widgetDialogItems" 
    modal="true" showEffect="fade" hideEffect="fade" resizable="false" width="1060">

    <h:form id="dialogFormArticulosPackage">

        <p:fieldset id="fieldSetPackage" widgetVar="widgetFieldSetPackage" legend="Add Service" toggleable="true" toggleSpeed="500" >

            <p:panelGrid id="panelGridPackageOne" columns="2" >
                <p:outputLabel value="Code:" for="newCode" />
                <p:outputLabel value="Description:" for="newDescription" />
                <h:panelGrid columns="2" >
                    <p:inputText id="newCode" widgetVar="widgetnewCode"
                             disabled="true" 
                             value="#{mainbean.propertyDTO.newCode}" />
                    <p:commandButton icon="fa fa-search" immediate="true" 
                                     oncomplete="AnotherAction..." />
                </h:panelGrid>
                <p:inputText id="newDescription" widgetVar="widgetnewDescription"
                             disabled="true" 
                             value="#{mainbean.propertyDTO.newDescription}" />
            </p:panelGrid>

            <p:panelGrid id="panelGridPackageTwo" columns="3" >
                <p:outputLabel value="Main Service:" for="newMainService"/>
                <p:outputLabel value="Order:" for="newOrder" />
                <p:outputLabel value="New" for="newService" />

                <p:selectOneMenu id="newMainService" value="#{mainbean.propertyDTO.newMainService}" >
                    <f:selectItem itemLabel="No" itemValue="N" />
                    <f:selectItem itemLabel="Yes" itemValue="Y" />
                </p:selectOneMenu>
                <p:spinner id="newOrder" value="#{mainbean.propertyDTO.newOrder}" min="0"/>
                <p:commandButton icon="fa fa-plus"
                                 value="Add"
                                 id="newService" actionListener="#{mainbean.savePackage()}"
                                 title="Add Service To Package"
                                 update="@widgetVar(widgetFieldSetPackage)" >
                </p:commandButton>
            </p:panelGrid>

        </p:fieldset>

    </h:form>
</p:dialog>

When the button with id=newService is pressed, mainbean.savePackage() is doing that propertyDTO = new PropertyDTO();

I want to change all inputs inside the my dialog.

I was trying with

update="@widgetVar(widgetFieldSetPackage) fieldSetPackage panelGridPackageOne panelGridPackageTwo"

Is it possible change all inputs contained in specific p:panelGrid ? Example: panelGridPackageOne

EDIT, according to recommendation:

update=":dialogFormArticulosPackage:fieldSetPackage:panelGridPackageOne :dialogFormArticulosPackage:panelGridPackageOne"

But is not working for me.

  • 1
    Uhhh... yes, by updating that id... Just make sure you reference it in the right way (since it is a sibbling of the parent of the commandButton) – Kukeltje Oct 17 '18 at 16:04
  • Possible duplicate of [How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"](https://stackoverflow.com/questions/8634156/how-to-find-out-client-id-of-component-for-ajax-update-render-cannot-find-compo) – Kukeltje Oct 17 '18 at 16:04
  • Thank you, I understanding but... how I know if a component `p:fieldset` is NamingContainer? And generically how identify what ever primefaces component? –  Oct 17 '18 at 16:24
  • See the duplicate. It has suggestions just for this first question. Regarding your second question, there is a Q/A in stackoverflow already – Kukeltje Oct 17 '18 at 17:28
  • We did not suggest either of those explicitly, we suggested to use the link posted to find the full client id. Your `update` seems to be contain two versions of the same attempt. But there might be other naming containers around the dialog. Did you run your application in development mode? Sure there are not errors as mentioned in the link? 'Does not work' is sort of hard to help with, without an [mcve] – Kukeltje Oct 18 '18 at 07:36

1 Answers1

1

I see all the components you want to update are inside the same h:form than the button that you want to fires that updating. Have you tried with update="@form"?

JuanH
  • 51
  • 3