2

I have a page with a form and an input text, that represents the value of a bean. On the bottom of the page, I have a navigation button to go to the next entry:

<h:form id="customerData">
...
    <h:outputText value="#{customeredit.customer.name}" />
    <br />
    <h:inputText size="60" id="name" value="#{customeredit.customer.name}" />
...
</h:form>

<p:commandButton value="Next customer" action="customers" ajax="false" id="nextCustomer">
    <f:param name="linkageAreaId" value="#{customeredit.nextCustomer.id}" />
</p:commandButton>

If I click on the button, the page reloads, a new customer object is loaded in the background and all the entries are updated EXCEPT the inputText. The outputText changes, but the inputText always keeps the value it has gotten when it was intialized. I also checked with the getters, the values return from the getters change with new customers, but the value displayed in the inputText always stays the same.

user1406177
  • 1,328
  • 2
  • 22
  • 36

1 Answers1

0

That can happen if you're nesting forms (which is illegal in HTML) and thus both the input and button ultimately end up in the same form. That button would then submit the input field as well. In any case, you should not be using <p:commandButton> for page-to-page navigation. Use <p:button> instead.

<p:button value="Next customer" outcome="customers" id="nextCustomer">
    <f:param name="linkageAreaId" value="#{customeredit.nextCustomer.id}" />
</p:button>

Don't forget to fix the nested form problem as well.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    I think nested forms throwing an error might depend on the browser being used. Afaik, the behaviour is 'undetermined' – Kukeltje Mar 16 '15 at 17:05