-
1. Re: custom status message
lvdberg Aug 7, 2009 10:02 AM (in response to roman.mandeleil1)Hi
possibly I am missing something, but you should use the class FacesMessages which is a subclass of StatusMessages. Maybe you've made your own custom class an didn't conigure it correctly ?
-
2. Re: custom status message
roman.mandeleil1 Aug 7, 2009 11:03 AM (in response to roman.mandeleil1)
Leo van den Berg wrote on Aug 07, 2009 10:02:
Hi
possibly I am missing something, but you should use the class FacesMessages which is a subclass of StatusMessages. Maybe you've made your own custom class an didn't conigure it correctly ?- Tried it also, unfortunately I got the same behavior.
I see two more symptoms:
1) If I add the rich:message element for the input also, it goes like that:
when hibernate validation fails I see two messages, but if the custom validation
fails I see only one message.2)The custom validation doesn't activates the field decorator, the field and the label
text stay black. -
3. Re: custom status message
lvdberg Aug 7, 2009 11:14 AM (in response to roman.mandeleil1)have you tried a simple add of fecaesMessages and does that work?
-
4. Re: custom status message
roman.mandeleil1 Aug 7, 2009 11:33 AM (in response to roman.mandeleil1)
Leo van den Berg wrote on Aug 07, 2009 11:14:
have you tried a simple add of fecaesMessages and does that work?Yes
-
5. Re: custom status message
lvdberg Aug 7, 2009 11:48 AM (in response to roman.mandeleil1)Roman,
send some additional code, because we need to see how you custom validator is made, configured and used.
Leo
-
6. Re: custom status message
roman.mandeleil1 Aug 7, 2009 2:59 PM (in response to roman.mandeleil1)Leo,
I am using very straight forward code, an EAR file that contains a WAR and an EJB jar.
I have the the JSF that tries to submit a new user:part of register.xhtml:
<seam:decorate id="userNameField" template="/decorate-template/form-field.xhtml"> <ui:define name="label">User Name:</ui:define> <h:inputText id="userName" required="true" value="#{loginDataForm.username}" maxlength="16"> <a4j:support event="onblur" reRender="userNameField" ajaxSingle="true"/> </h:inputText> </seam:decorate>
form-field.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib"> <div> <s:label styleClass="name #{invalid?'errors':''}"> <s:span styleClass="required" rendered="#{required}">*</s:span> <ui:insert name="label" /> </s:label> <span class="value #{invalid?'errors':''}"> <s:validateAll> <ui:insert /> </s:validateAll> </span> <span class="error"> <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors" /> <s:message id="message" styleClass="errors" /> </span> </div> </ui:composition>
part of RegistrationManagerImpl SLSB:
try { entityManager.createQuery( "select u from User u where " + "u.username='" + loginDataForm.getUsername() + "'") .getSingleResult(); statusMessages.addToControl("userName", Severity.ERROR, "User with that name already exist"); return; } catch (NoResultException e) { // The user can be registered }
form that gets the data from the JSF and injects into the SLSB:
@Name("loginDataForm") public class LoginDataForm { @NotEmpty @Length(min=3,max=16) private String username; @NotEmpty @Length(min=3,max=10) private String password; private String passwordConfirm; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getPasswordConfirm() { return passwordConfirm; } public void setPasswordConfirm(String passwordConfirm) { this.passwordConfirm = passwordConfirm; } public boolean passwordConfirmed(){ if (password == null) return false; if (passwordConfirm == null) return false; return this.password.equals(passwordConfirm); } }
I am using Seam 2.1.2 and Rich Faces 3.3.2, I hope it is
clear enough, if not I'll try to work out a sample.Thanks in advance.
Roman -
7. Re: custom status message
lvdberg Aug 7, 2009 3:19 PM (in response to roman.mandeleil1)It seems that it can't find the specific JSF-control to ad it to. Some possible hints:
- Look in the HTML-source code if the specific id exists,
- Try this out without the form-field.xhtml template,
- Create a separate fixed JSF-Control without any templates, and use the specific Id on it.Leo
P.S. My weekend just started, so it can take some more time to reply.
-
8. Re: custom status message
seam2012 Jun 19, 2012 6:04 AM (in response to roman.mandeleil1)Hi, I met the same problem. Has anyone found the cause of the problem? Thanks!