0

I am developing a project using primefaces.

Code:

<p:panel id="accountPolicyRichPanel">
    <h:panelGrid id="outputPanelGrid">

         <h:outputText value=""...../>
         <p:inputText id="InputTextId"/>

        <p:selectOneMenu id="suspendTypeId" value="...">
             <f:selectItems value="#{AccountPolicy.suspendTypeItemList}"/>
             <p:ajax listener="#AccountPolicy.suspendTypeComboboxAction}"event="change" update="outputPanelGrid"/>
        </p:selectOneMenu>
   </panelGrid>

        <p:commandButton id="saveButtonId" value="..." action="..."
              update="accountPolicyRichPanel" />

</p:panel>

My issue is when i select the <p:selectOneMenu> I upadte the <h:panelGrid id="outputPanelGrid"> at the time my previous entered value in <p:inputText id="InputTextId"/> is removed.

How to update the <h:panelGrid id="outputPanelGrid"> or <p:panel> without remove the previous entered value in p:inputText.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
VenRaj
  • 27
  • 6

2 Answers2

0

You must exclude <p:inputText id="InputTextId"/> from update or add this input to execute, because Ajax processes by default only the current component as in execute="@this".

e.g. implementation: <p:ajax process="outputPanelGrid" listener="#{AccountPolicy.suspendTypeComboboxAction}"event="change" update="outputPanelGrid"/>

sQer
  • 1,136
  • 8
  • 9
  • 1
    You are wrong, the default of the process attribute in PrimeFaces is @Form, see http://stackoverflow.com/questions/25339056/understanding-process-and-update-attributes-of-primefaces. What the OP should at least do is to use an `value="#{bean.someField}"` – Kukeltje May 15 '15 at 07:38
  • You are right, has as default execute set to @this. Thanks for correction – sQer May 15 '15 at 07:52
0

You should at least put an value="#{bean.someField}" on the inputText. When that is not present, the value you type in will get lost in the process of the ajax submit and update since it cannot be stored on the server. This is all basic jsf and not PF related.

You might be able optimize form submission (what field is submitted and what is not, which is processed and which is not) but that is:a different thing

See also

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47