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?
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.
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.
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.
Post by:autobot
Get out of my mind! Look! A tiny ad!
a bit of art, as a gift, that will fit in a stocking