• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

simple jsf form

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you try with this button

<h:commandButton id="redisplayCommand" type="submit" value="save"
actionListener="#{commandProtectionManager.update}"/>
 
Saloon Keeper
Posts: 25453
178
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
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.

 
Die Fledermaus does not fear such a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic