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();" />