0

I have the scenario where the user can enter some data to the input fields but it must be also able to add some links to a list. I have two forms - one for the input fields and one for the selectOneListbox. The problem is that when the user fills the data inside the first form and then press Complete button it is changing the view successfully but it shouldnt as there is no data in the list box here is my code so far:

<h:form id="mainForm">

    <p:inputText id="name" required="true"               
                 value="#{data.name}"
                 maxlength="20">
    </p:inputText>

    <p:inputText id="version" required="true"                
                 value="#{version}"
                 maxlength="20">
    </p:inputText>

    <p:remoteCommand name="remoteClose"
                 actionListener="#{logic.close}" 
                 update="mainForm" />
</h:form>

<h:form id="secondaryForm">

    <p:selectOneListbox id="requirementsUrl" 
                        value="#{data.selectedURL}">
                <f:selectItems value="#{data.documents}" />
    </p:selectOneListbox>
    <p:commandButton actionListener="#{logic.addURL}"
                     update="secondaryForm" 
                     value="Add" />
    <p:remoteCommand name="secondUpdate" 
                     update="secondaryForm">
                     </p:remoteCommand>
</h:form>
<p:commandButton id="completeOne" 
                 type="button"
                 value="Complete"
                 onclick="secondUpdate();remoteClose();" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • how your managed bean look like? – Youcef LAIDANI Mar 15 '17 at 07:07
  • Why do you use multiple forms, remote commands and have your button outside any form? I think you are making it more complex than it needs to be. Also, you might want to learn about the PrimeFaces `process` attribute. See [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](http://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – Jasper de Vries Mar 15 '17 at 12:13

0 Answers0