IntelliJ Java IDE
The moose likes JSF and the fly likes simple jsf form Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "simple jsf form" Watch "simple jsf form" New topic
Author

simple jsf form

Vitaliy Kravchenko
Greenhorn

Joined: Dec 02, 2010
Posts: 10
I have a jsf like that:




I need to submit form in backing bean and to invoke method commandProtectionManager.update
My code doesn't work
How can I achieve this result? Thanks
Jhonnathan Emilio Cardona Saineda
Greenhorn

Joined: Jan 24, 2012
Posts: 11

you try with this button

<h:commandButton id="redisplayCommand" type="submit" value="save"
actionListener="#{commandProtectionManager.update}"/>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12513

I do not recommend using ActionListeners. They have their place, but a straight action method is the better way 99 times out of 100. The reason we have so many ActionListeners polluting JSF I suspect is that too many people learned JSF from out-of-date documentation.

I'm assuming that the form was defined within a JSF view element, that the WEB-INF/web.xml was properly configured for JSF and that the view was requested via its JSF URL and not via its resource path. Those are fundamental requirements for JSF to work.

If all of the above conditions have been met, there's still one more. JSF requires an all-or-nothing set of valid data. If any data value on a submitted form fails validation, then the backing bean will not be updated and the action method (and/or actionListeners) will not be executed.

If there's any doubt, add an "h:messages" tag to the page to display the validation messages.

Also, one other thing. "ajaxSingle" reduces the amount of data that will be sent to the server to only the indicated control. Specifically the "user id" and "password" values will not be processed and will not update the backing bean.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
 
jQuery in Action, 2nd edition
 
subject: simple jsf form
 
Threads others viewed
Passing parameters with h: link
Issue with my webApp
Not able to run simple JSF
how to skip validation phase only
dealing with jsf components in java script
developer file tools