Forums Register Login

JSTL and bean data

+Pie Number of slices to send: Send
I have a JSF application where on one side is a navigation area where each link represents a form to be filled out:


And the other side is a form. As the user completes the form, they can either click a 'Next' button to navigate to the next form, or click a link in the navigation bar. The problem I am running into is, if the user clicks the navigation link, the data entered in the form is not saved in the bean. What can I add to the above code to make sure the data is saved in the bean?

Thank you.
+Pie Number of slices to send: Send
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP not JSF. For more information, please read this.

This post has been moved to a more appropriate forum.

+Pie Number of slices to send: Send
Actually, that's NOT a JSF page - it's a JSP, so it was originally posted in the correct forum, just mislabelled.

However, it's missing some things. It claims to be a "form", but there's no HTML <form> tag in sight, and without that, data won't be submitted back to the server.

The other thing it appears to be missing is an actual input control. So there's nothing defined for submission even if the form is defined.
+Pie Number of slices to send: Send
The code I posted is just for the creation of the side navigation. This navigation is dynamically created and is a fragment. Below is what one of the full page code looks like.

Do I need to put the <form> </form> in the fragment for the navigation?
Thank you.
+Pie Number of slices to send: Send
For straight href links, you don't need a form. However, for JSF h:commandLinks, I believe you do. There.s a JSF control that corresponds to the <a> tag: <h:outputLink>.

There's no advantage I could see to using JSTL for this, however - a JSF dataTable would do the same job.

Mixing JSF and JSTL is generally not a good idea. In fact, mixing JSF and HTML is actually not so great, if you can avoid it.

Going back to the original question, using anything that results in an <a href=> (including h:outputLink) will not update your backing bean, because backing beans need to be posted, and posting is done by a form.

If you want the backing bean updated, use the h:commandLink instead. Which has to be inside the same form as the backing bean data references.
Get out of my mind! Look! A tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3216 times.
Similar Threads
setting a session variable in a 'href'
Simple form: inputText does not reset
How to loop through data on a jsp form?
Data issues on a SessionScoped managedbean JSF 2
JSP column name hyperlink help
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:25:30.