• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL and bean data

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kimberly Lewis
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic