[jboss-user] [Beginner's Corner] - How to load the form values automatically?

Francisco Palma do-not-reply at jboss.com
Thu Apr 19 15:28:57 EDT 2012


Francisco Palma [https://community.jboss.org/people/fpalma] created the discussion

"How to load the form values automatically?"

To view the discussion, visit: https://community.jboss.org/message/731169#731169

--------------------------------------------------------------
Hi all!

I have done a servlet to manage one form, but when I want to get the values introduced by the user, I have to access to the parameter of the form and update manually the class corresponding to the parameter. This is my code:

When the jsp file is loaded, the user sees the default value from the class "priceIncrease": 

    <input name="increasepercent" path="percentage" value="${priceIncrease.getPercentage()}" />

When the method doPost is called by the form, the class "priceIncrease" is not updated with the value modified by the user, so I have to do this:

    String increase1 = (String) request.getParameter("increasepercent");                     // access to the parameter of the form
    PriceIncrease increase2 = (PriceIncrease) contexto.getAttribute("priceIncrease"); // access to the corresponding class 
    increase2.setPercentage(Integer.parseInt(increase1));                                            // update the class

How can I update the corresponding class (priceIncrease) automatically?

Thank you very much
Fran
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/731169#731169]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120419/d8315d19/attachment-0001.html 


More information about the jboss-user mailing list