-
1. Re: Seam FacesMessages with its createFacesMessage method an
pmuir Feb 10, 2007 11:30 AM (in response to fernando_jmt)You can use:
FacesMessages.instance().addFromResourceBundle(getClientId(facesContext), severity, key, params);
-
2. Re: Seam FacesMessages with its createFacesMessage method an
fernando_jmt Feb 10, 2007 3:27 PM (in response to fernando_jmt)"petemuir" wrote:
You can use:FacesMessages.instance().addFromResourceBundle(getClientId(facesContext), severity, key, params);
I tried what you suggest me before posting the message here. But it does not work.
This because the ValidatorException has this signature when creating it:public ValidatorException(javax.faces.application.FacesMessage facesMessage)
So, I need a FacesMessage in order to use it for the ValidatorEception constructor.
This is was I tried:FacesMessages.instance().addFromResourceBundle(uiComponent.getId(), FacesMessage.SEVERITY_ERROR, MESSAGE_KEY, messageParams); throw new ValidatorException(new FacesMessage());
But adding above code does not work. It validates, but no message appear in the page. So, FacesMessages.instance().addFromResourceBundle() does not work in this situation.
I also tried this and this works:FacesMessage message =FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, "The value (#0) is not equal with value of #1", messageParams); throw new ValidatorException(message);
But in the above code the problem is that there is no way to create a FacesMessage from resource bundle. This is the reason because I suggest to add the method I mentioned before.
Is there something I am missing?
There is another way?
Thanks in advance. -
3. Re: Seam FacesMessages with its createFacesMessage method an
pmuir Feb 10, 2007 5:20 PM (in response to fernando_jmt)Seems like a good idea. Please put it in JIRA
-
4. Re: Seam FacesMessages with its createFacesMessage method an
fernando_jmt Feb 11, 2007 4:54 PM (in response to fernando_jmt)JIRA issue reported.
http://jira.jboss.org/jira/browse/JBSEAM-818 -
5. Re: Seam FacesMessages with its createFacesMessage method an
cdupont Jan 21, 2008 8:52 AM (in response to fernando_jmt)My solution:
public void validate(FacesContext context, UIComponent cmp, Object value)
throws ValidatorException
{
if (ValidationUtils.validateEmail((String) value))
{
MemberManager memberManager = (MemberManager) Component
.getInstance("memberManager");
if (!memberManager.isUsernameAvailable((String) value))
{
String msg = ResourceBundle.instance().getString(
"validation.member.email.taken");
FacesMessage errorMessage = new FacesMessage();
errorMessage.setDetail(msg);
errorMessage.setSummary(msg);
errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(errorMessage);
}
}
else
{
String msg = ResourceBundle.instance().getString(
"validation.member.email.invalid");
FacesMessage errorMessage = new FacesMessage();
errorMessage.setDetail(msg);
errorMessage.setSummary(msg);
errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(errorMessage);
}
}
}