I have a PrimeFaces dialog where I am asking for user details. I simplified it to have only one input text like the one below.
<p:dialog>
<h:form prependId="false">
<p:growl showDetail="false" autoUpdate="true" life="4000"/>
<p:panelGrid columns="2">
<h:outputText value="First Name" />
<p:inputTextarea required="true" requiredMessage="First Name is required!" />
<p:commandButton value="Add" actionListener="#{myBean.addUser}"/>
</p:panelGrid>
</h:form>
</p:dialog>
I notice that when I don’t input my first name, my action listener isn’t called which I think is normal since required="true" validation already happened.
Is there a way to configure this, where my action listener will still be called?
or do I have to remove the required="true" checking and put all the validation in my action listener method?
You should not put validation logic into an action method.
If you need to do more validation than the required-check, use a custom validator for this. The action method should simply add the user and should rely on the jsf validation phase.
See this link on the different validation options for more information.