[jboss-user] [JBoss Seam] - Re: Validator in Bean

valtoni do-not-reply at jboss.com
Thu Jul 26 10:57:00 EDT 2007


"demetrio812" wrote : Hi,
  | 
  |   | 	public void validaEmailNewsletter(FacesContext context, UIComponent toValidate, Object value) {
  |   | 		if (isEmailInserita((String)value)) {  // se c'è già
  |   | 			FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Attenzione: l'indirizzo email è già stato registrato", "Attenzione: l'indirizzo email è già stato registrato");
  |   | 			throw new ValidatorException(message);
  |   | 		}
  |   | 	}
  |   | 
  | 

Demetrio, don't use throws in methods exposed in Seam context session: jsf catch this exception and the enviroment will catch this, showing the page error wich you post here. You must throw exception like a "Blog Application", wich come with seam distribution; you must declare the Throwable class, like the example:

@ApplicationException(rollback=true)
  | @HttpError(errorCode=HttpServletResponse.SC_NOT_FOUND)
  | public class EntryNotFoundException extends Exception
  | {
  |    EntryNotFoundException(String id)
  |    {
  |       super("entry not found: " + id);
  |    }
  | }

and mark your method like


  | 	public void validaEmailNewsletter(FacesContext context, UIComponent toValidate, Object value)  throws EntryNotFoundException
  | 

And demark your right annotations to be rightly redirected. Ok?


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

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




More information about the jboss-user mailing list