Input text fail to validate
kjav Oct 10, 2012 12:11 AMHi all, I've been following closely to the codes from dataTableEdit.xhtml in RichFaces Showcase. TIll now, I had successfully implemented a datatable to display a list of user from database which include filtering and sorting. Im currently working on editing user row which I get the current user id when I click on the row and show the pop out panel. The panel allows the particular user information to be edited. I wanted to implement javax validation but it fails to show the error message when I input a invalid string. Im not sure the way I use param value to pass user id and assign to currentUserid is correct (highlighted in red). Here's part of my code:
My table.xhtml
<rich:column>
<f:facet name="header">Action</f:facet>
<a4j:commandLink execute="@this" render="@none" oncomplete="#{rich:component('confirmPane')}.show()">
<h:graphicImage value="/resources/images/common/user_delete.png" />
<a4j:param value="#{user.id}" assignTo="#{userUpdateBean.currentUserId}" />
</a4j:commandLink>
<a4j:commandLink render="editGrid" execute="@this" oncomplete="#{rich:component('editPane')}.show()">
<h:graphicImage value="/resources/images/common/user_edit.png" />
<a4j:param value="#{user.id}" assignTo="#{userUpdateBean.currentUserId}" />
</a4j:commandLink>
</rich:column>
<rich:popupPanel header="Edit User Details" id="editPane" domElementAttachment="parent" width="400" height="170">
<h:panelGrid columns="3" id="editGrid">
<h:outputText value="Username" />
<h:inputText value="#{userUpdateBean.selectedUser.username}" id="userName">
<rich:validator/>
</h:inputText>
<rich:message for="userName" />
<h:outputText value="Email" />
<h:inputText value="#{userUpdateBean.selectedUser.email}" id="userEmail">
<rich:validator/>
</h:inputText>
<rich:message for="userEmail" />
<h:panelGroup/>
</h:panelGrid>
<a4j:commandButton value="Store" render="table" execute="editPane"
oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}" action="#{userManagedBean.store}"/>
<a4j:commandButton value="Cancel" onclick="#{rich:component('editPane')}.hide(); return false;" />
</rich:popupPanel>
My user class
@Pattern(regexp = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[a-zA-Z]{2,4}$" , message="Invalid email address")
public String getEmail() {
return email;
}
@Size(min=3, max=40)
@Pattern(regexp="^[a-zA-Z0-9]+$")
@NotBlank
@Column(unique = true)
@Field
public String getUsername() {
return username;
}