This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
How to preserve input elements values after a submit? I looked at the tomahawk docs and it seems that t:subform can be used to preserve elements during a submit. The problem with this is that I have some plain html elements in my web application and placing a t:subform around these elements does not seem to preserve their values after a submit has occurred. Trinidad has a partialsubmit that may possibly work, and I will look into it.
During a submit I do not want to send everything on the page back to the server, instead I only want to send one subform to the server.
Could you possibly organize the components you want to submit into separate form tags?
Form data isn't usually too verbose, compared to all the other data sent across a network, especially things like images and video. What's the big issue with sending a few extra bytes of data over the network?
Joined: Jan 09, 2009
I am not worried about the bandwidth. The user expects these elements to remain on the page with whatever style changes they have made.
The basic JSF architecture should be doing that for you. If you create a JSF view with a form on it, submit the form, and don't navigate to some other view, the original page should be resdisplayed with the updated values (assuming your backing beans set/get methods are all correct).
If you have multiple forms on a page, this rule changes somewhat, since JSF is building on HTTP and HTTP only supports submitting one form per request. So only the submitted form will update. Any other forms on the page will lose their client-side changes and be refreshed from the server. The server literally never sees the client-side changes for the other forms.
Sometimes that's not a good idea. Fortunately, now we have AJAX solutions that support partial page updating. In Rich Faces, for example, you can designate each form as an AJAX form and instruct it to reRender itself but not any of the rest of the page (unless you want to).
An IDE is no substitute for an Intelligent Developer.