简体   繁体   中英

jsf inputtext to bean

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?

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 etc) 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM