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?
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.