Reputation: 901
I have just changed the way a user enters data, from using <h:
to <:p
from the primefaces library, and now when the data has been successfully added to the database it no longer automatically takes the user to relevent pages. The only changes I have made is instead of using the code below to enter data:
<h:messages showDetail="true" />
<h:outputText value="Enter Name : " />
<h:inputText value="#{user.name}" />
<br></br>
<h:outputText value="Enter email address : "/>
<h:inputText id="email" value="#{user.email}"
size="20" required="true" label="Email Address">
<f:validator validatorId="richard.test.EmailValidator" />
</h:inputText>
<br></br>
<h:outputText value="Enter your address : "/>
<h:inputText value="#{user.address}" />
<br></br>
<h:outputText value="Enter Created Date : "/>
<h:inputText value="#{user.created_date}">
<f:convertDateTime pattern="yyyy-MM-dd"/>
</h:inputText>
<br></br>
<br></br>
<h:message for="email" style="color:red" />
<h:commandButton value="Insert" action="#{user.add}"/>
The above code still works if I run that instead of the code below:
<h:form>
<p:growl id="growl" showDetail="true" sticky="true" />
<p:panel header="Growl">
<h:panelGrid columns="2">
<h:outputText value="Enter Name : " />
<h:inputText value="#{user.name}" required="true" />
<h:outputText value="Enter email address : " />
<h:inputText id="email" value="#{user.email}" size="20" required="true" label="Email Address">
<f:validator validatorId="richard.test.EmailValidator" />
</h:inputText>
<h:outputText value="Enter your address : " />
<h:inputText value="#{user.address}" />
<h:outputText value="Enter Created Date : " />
<h:inputText value="#{user.created_date}">
<f:convertDateTime pattern="yyyy-MM-dd" />
</h:inputText>
</h:panelGrid>
<p:commandButton value="Save" actionListener="#{user.add}" update="growl" />
</p:panel>
</h:form>
<h:form>
<h:messages showDetail="true" />
</h:form>
The reason behind the change was to make a better look for the user, but while it looks professional and adds all the data to the database it no longer sends the user to a page is successful etc, although the faces-config.xml
file has not changed. The only change is the use of primefaces. What would be causing this, and is there a way on successful input of data to take the user to the right page?
Thanks.
Upvotes: 0
Views: 36
Reputation: 510
Your p:commandButton invokes user.add
as actionListener instead of action like the h:commandButton in your first example. Simply switch to action, that should lead to the behaviour you want it to have.
Upvotes: 2
Reputation: 1870
If you want to make use of JSF's implicit navigation change actionListener
-attribute in your <p:commandButton>
to action
. That's it.
Upvotes: 0