Posts Tagged ‘jsf commandButton’

Hi there! Very quick note today 🙂

If you’re having issues with your h:commandButton with your ManagedBean refusing to run the action method, don’t dispair. There is a simple tutorial to fix it:

1) Watch out for your validation method syntax. The validation method in your ManagedBean MUST return a String and take no argument when using the ‘action’ attribute of your h:commandButton. This will be the page where you’ll end up (if you want,you can also return “” and use navigation strategies to redirect the user) .  However, if you’re using actionListener, you must use ActionEvent as an argument to your validation method.

2) Check if your h:commandButton its nested inside a h:form. It must be. Also, it’s better to also use f:view and nest the form inside it.

3) Don’t go around the web searching, ‘oh my god my form action doesn’t work!!’. Most times the error is in the attributes inside the form, not in the method itself. A common one is to forget those ‘required=true’ on your h:inputText and simply push the “submit” button without filling them. Most times, nothing will happen (especially when you don’t have error messages) and leave you wondering!

Well that’s it!! Cumps! 😀


Read Full Post »