0

In my JSF Application, I have a page with several inputtext components. When the page is displayed, those inputtext components are populated with data from the database. When I hit the submit button, I want to pass those values as parameters to the next facelet.

What is happening is when I hit Submit, the old values are being passed, and not the updated values that the user has typed in. Here is what one of the inputtext components looks like:

 <div align="center"> <h:outputLabel value="Product Quantity " /> <h:inputText id="quantity" value="#{product.quantity}" /> </div> 

Then, in the submit button I am trying to get the values that the user types in:

 <h:button value="Save Edits" outcome="welcome"> <f:param name="quantity" value="#{product.quantity}" /> </h:button> 

Let's say that 100 was the original quantity that the field was populated with. When the user changes it to 110, and hits submit, the welcome facelet still thinks 100 is the value. Any ideas?

1
  • You have to use a h:commandButton instead of a normal h:button, tis should fix it! Commented Jun 29, 2017 at 23:45

1 Answer 1

1

Is there any particular reason you've decided to use a <h:button/> instead of an <h:commandButton/>? Because that's the reason why your parameters are not making it to the next page

<h:commandButton/> processes it's enclosing <h:form/>, submitting it's content to the server in a POST request (and the JSF processing lifecycle kicks in e.t.c.) while the <h:button/> will generate a GET request. <h:button/> is generally used for navigation. Stick to <h:commandButton/> if you want to do more than navigate

Sign up to request clarification or add additional context in comments.

5 Comments

Just as a sidebar, I have a Product bean and a ProductList bean in my app. The ProducList just has an ArrayList<Product>. I have the app setup to just allow the user to add products to the database, and I'm trying to display them in a table. The items are in the database, I can see them, but for some reason the table is showing 0's for the 2 int values, and blanks for the 2 strings that make up a Product object, leading me to believe that the Products are being overwritten? Could it have anythihg to do with the scope?
@user1154644 It'll be difficult to tell what's going on for sure without seeing code, but yes, the scoping of the backing bean could be the reason why. Are you saying that there are two blank rows being displayed in the datatable?
well, the product has attributes that are int, string, string, int. And the table is showing 0's for the int columns, and blanks for the 2 string columns. Is there anything you can suggest? I think right now the ProuctList and the Product beans dont have any scope annotations, but I cant figure out if I should make them application or view scope. This is just a school assignment that is almost done, this is the only thing I cant get figured out. The productlist is what I'm iterating over to display the table.
@user1154644, you need to put some code up here (in another question). Guessing is not going to sort it out
sure ill start a new question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.