[jboss-user] [JBoss Seam] - Re: Problem: Custom validate methods in EJBs crash

krica do-not-reply at jboss.com
Mon Mar 5 08:33:17 EST 2007

I know this is an old thread, but I ran into the same problem with the ValidatorException causing the crash. After much trial and error, this is the solution I have come up with. I thought it may be useful for others, at least once I get the last little niggle out of it, which I don't think is relevant to the problem at hand.

At the bottom of my form, I create a hidden input field, with a dummy value and a bound validator method. In this method, I then get the components I'm interested in and validate the values. If a field is deemed invalid, the flag it as such and add a message to the context. E.g.

  |     public void validateForm(FacesContext context, UIComponent component, Object value) throws ValidatorException {
  |         HtmlInputText theInputText = (HtmlInputText) context.getViewRoot().findComponent("myForm:myInputId");
  |         String theValue = (String) faxInputText.getValue();
  |         if ("anError".equals(theValue)) {
  |             theInputText.setValid(false);
  |             context.addMessage(theInputText.getClientId(context), FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, "This is an error!"));            
  |         }
  |     }

My only problem left is that sometimes, for some reason, the method does not get called.

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025041

More information about the jboss-user mailing list