See the posted code below to see how to validate the input.

  | /**
  |  * @author Thomas Maerz ([EMAIL PROTECTED])
  |  */
  | @Name("userHome")
  | public class UserHome extends EntityHome<User> {
  | 
  |     private static final long serialVersionUID = 1L;
  | 
  |     @In
  |     UserDao userDao;
  | 
  |     public void validateUsername(FacesContext context, UIComponent 
component, Object value) throws ValidatorException {
  |             User user = userDao.getByUsername((String) value);
  |             if (user == null || user.getId().equals(getInstance().getId())) 
{
  |                     return;
  |             }
  |             throw new ValidatorException(new FacesMessage(""));
  |     }
  | }
  | 

edit.html

  |     <s:decorate template="/templates/edit.html">
  |             <ui:define name="label">Username</ui:define>
  |             <h:inputText value="#{userHome.instance.username}" 
validator="#{userHome.validateUsername}" required="true"/>   
  |     </s:decorate>
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125131#4125131

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125131
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to