Meaningless Drivel is fun!*
The moose likes JSF and the fly likes JSTL and bean data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSTL and bean data" Watch "JSTL and bean data" New topic
Author

JSTL and bean data

Kimberly Lewis
Greenhorn

Joined: May 12, 2009
Posts: 2
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kimberly Lewis
Greenhorn

Joined: May 12, 2009
Posts: 2
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

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.
 
 
subject: JSTL and bean data