1) <rich:ajaxValidator is making the user have to provide a valid value to navigate the page. How to navigate the same without providing a inputs in phone anme, since the user doest not want to save the data.He is interest to cancel the save operation.
1)Phone.xthml
<ui:define name="body">
<h:form id="ajaxValidatorForm2">
<rich:toolBar itemSeparator="line" width="350" height="30">
<h:commandLink value="#{msg.new}" action="#{phoneType.newPhoneType}" />
<h:commandLink value="#{msg.view}" action="#{phoneType.newPhoneType}" />
<h:commandLink value="#{msg.Modify}" action="#{phoneType.newPhoneType}" />
<h:commandLink value="#{msg.save}" action="#{phoneType.savePhoneType}" />
<h:commandLink value="#{msg.cancel}" action="#{phoneType.newPhoneType}" />
//The canel is not navigation,
// Problem, I have to enter a valid input in PhoneName then click on cancel it's navigate,otherwise it's asking input.
</rich:toolBar>
<h:panelGrid columns="3" bgcolor="#e6edfd" styleClass="tbl-forms"
columnClasses="even,odd">
<h:outputLabel value="#{msg.phoneName}" for="" />
<h:inputText value="#{phoneBean.phoneName}" id="phoneName" required="false"
size="28" maxlength="3">
<rich:ajaxValidator event="onblur" />
</h:inputText>
</ui:define >
3)PhoneBean.java
public class PhoneBean {
@NotEmpty
@Pattern(regex=".*[^\\s].*", message="This string contain only spaces")
@Length(min=3,max=12)
private String phoneName;
public String getPhoneName() {
return phoneName;
}
public void setPhoneName(String phoneName) {
this.phoneName = phoneName;
}
}
SEE image ajaxValidator.GIF for more clarifications.