[JBoss Seam] - Re: Validation: @NotNull && required=true
by monkeyden
There is no way to do it globally but you can use a phase listener:
import java.util.Iterator;
|
| import javax.faces.application.FacesMessage;
| import javax.faces.component.UIComponent;
| import javax.faces.component.UIViewRoot;
| import javax.faces.context.FacesContext;
| import javax.faces.event.PhaseEvent;
| import javax.faces.event.PhaseId;
| import javax.faces.event.PhaseListener;
|
| /**
| * Example messages.properties entries:
| * javax.faces.validator.LengthValidator.MAXIMUM="[fieldLabel]" value is greater than allowable maximum of {0} characters.
| * javax.faces.validator.LengthValidator.MINIMUM="[fieldLabel]" value must contain at least {0} characters.
| */
|
| @SuppressWarnings("serial")
| public class MessageListener implements PhaseListener {
|
| public PhaseId getPhaseId() {
| return PhaseId.RENDER_RESPONSE;
| }
|
| public void beforePhase(PhaseEvent e) {
| FacesContext fc = e.getFacesContext();
| UIViewRoot root = fc.getViewRoot();
| Iterator i = fc.getClientIdsWithMessages();
| while (i.hasNext()) {
| String clientId = (String) i.next();
| if(clientId != null) {
| UIComponent c = root.findComponent(clientId);
| if (c != null) {
| String fieldRef =
| (String) c.getAttributes().get("fieldLabel");
| if (fieldRef != null) {
| Iterator j = fc.getMessages(clientId);
| while (j.hasNext()) {
| FacesMessage fm = (FacesMessage) j.next();
| String s = fm.getSummary();
| s = s.replaceFirst("\\[fieldLabel\\]", fieldRef);
| fm.setSummary(s);
| }
| }
| }
| }
| }
| }
|
| public void afterPhase(PhaseEvent e) {
| }
| }
|
Then specify the fielLabel in the f:attribute tag:
<h:inputText value="#{contactUs.email}" size="50" maxlength="75" required="true">
| <f:attribute name="fieldLabel" value="Email"/>
| </h:inputText>
Or, if you require completely different messages for each component, you could specify a resource bundle key
<h:inputText value="#{contactUs.email}" size="50" maxlength="75" required="true">
| <f:attribute name="bundleKey" value="contactus.error.email.required"/>
| </h:inputText>
Using the latter approach, you would get the resource bundle key from the component attributes map in the listener and replace the summary text altogether.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045194#4045194
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045194
19 years, 1 month
[JBoss Seam] - Re: Validation: @NotNull && required=true
by tony.herstell@gmail.com
I think thisis what you are after:
| javax.faces.component.UIInput.CONVERSION Conversion error occurred
| javax.faces.component.UIInput.REQUIRED required
| javax.faces.component.UISelectOne.INVALID Value is not a a valid option
| javax.faces.component.UISelectMany.INVALID Value is not a valid option
| javax.faces.validator.NOT_IN_RANGE Specified attribute is not between the expected values of {0} and {1}
| javax.faces.validator.DoubleRangeValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| javax.faces.validator.DoubleRangeValidator.MINIMUM Value is less than allowable minimum of '{0}'
| javax.faces.validator.DoubleRangeValidator.TYPE Value is not of the correct type
| javax.faces.validator.LengthValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| javax.faces.validator.LengthValidator.MINIMUM Value is less than allowable minimum of '{0}'
| javax.faces.validator.LongRangeValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| javax.faces.validator.LongRangeValidator.MINIMUM Value is less than allowable minimum of '{0}'
| javax.faces.validator.LongRangeValidator.TYPE Value is not of the correct type
|
|
put into a file in my War Src area.
I refer to it in my faces.config
| <!-- My Messages Please -->
| <application>
| <message-bundle>nz.co.risingstars.i18n.jsfstandarderrors</message-bundle>
| </application>
|
This is on top of the messages you put into the messages.properies in the jar.
(there are a LOT more message that just this list!):
| javax.faces.component.UIInput.CONVERSION error
| javax.faces.component.UIInput.CONVERSION_detail = invalid
| javax.faces.component.UIInput.REQUIRED required
| javax.faces.convert.DateTimeConverter.CONVERSION = must be a valid date
| #javax.faces.convert.DateTimeConverter.CONVERSION_detail = value must be a datetime
|
| #javax.faces.component.UISelectOne.INVALID Value is not a a valid option
| #javax.faces.component.UISelectMany.INVALID Value is not a valid option
| #javax.faces.validator.NOT_IN_RANGE Specified attribute is not between the expected values of {0} and {1}
| #javax.faces.validator.DoubleRangeValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| #javax.faces.validator.DoubleRangeValidator.MINIMUM Value is less than allowable minimum of '{0}'
| #javax.faces.validator.DoubleRangeValidator.TYPE Value is not of the correct type
| #javax.faces.validator.LengthValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| #javax.faces.validator.LengthValidator.MINIMUM Value is less than allowable minimum of '{0}'
| #javax.faces.validator.LongRangeValidator.MAXIMUM Value is greater than allowable maximum of '{0}'
| #javax.faces.validator.LongRangeValidator.MINIMUM Value is less than allowable minimum of '{0}'
| #javax.faces.validator.LongRangeValidator.TYPE Value is not of the correct type
|
| #javax.faces.convert.DateTimeConverter.CONVERSION = Conversion Error
| #javax.faces.convert.DateTimeConverter.CONVERSION_detail = "{1}": xxSpecified value is not a valid date/time.
| #javax.faces.converter.DateTimeConverter.DATE=value must be a date
| #javax.faces.converter.DateTimeConverter.DATE_detail=value must be a date, eg. {1}
| #javax.faces.converter.DateTimeConverter.TIME=value must be a time
| #javax.faces.converter.DateTimeConverter.TIME_detail=value must be a time, eg. {1}
| #javax.faces.converter.DateTimeConverter.DATETIME=value must be a date and time
| #javax.faces.converter.DateTimeConverter.DATETIME_detail=value must be a date and time, eg. {1}
| #javax.faces.converter.DateTimeConverter.PATTERN_TYPE=a pattern or type attribute must be specified to convert the value
| #JSF 1.1:
| #javax.faces.convert.BigDecimalConverter.CONVERSION = value must be a number
| #javax.faces.convert.BigDecimalConverter.CONVERSION_detail = value must be a number
| #javax.faces.convert.BigIntegerConverter.CONVERSION = value must be an integre
| #javax.faces.convert.BigIntegerConverter.CONVERSION_detail = value must be a number
| #javax.faces.convert.BooleanConverter.CONVERSION = value must be true or false
| #javax.faces.convert.BooleanConverter.CONVERSION_detail = value must be true or false
| #javax.faces.convert.ByteConverter.CONVERSION = value must be a byte
| #javax.faces.convert.ByteConverter.CONVERSION_detail = value must be a byte
| #javax.faces.convert.CharacterConverter.CONVERSION = value must be a character
| #javax.faces.convert.CharacterConverter.CONVERSION_detail = value must be a character
| #javax.faces.convert.DoubleConverter.CONVERSION = value must be a number
| #javax.faces.convert.DoubleConverter.CONVERSION_detail = value must be a number
| javax.faces.convert.FloatConverter.CONVERSION = value must be a number
| javax.faces.convert.FloatConverter.CONVERSION_detail = value must be a number
| #javax.faces.convert.IntegerConverter.CONVERSION = value must be an integer
| #javax.faces.convert.IntegerConverter.CONVERSION_detail = value must be an integer
| #javax.faces.convert.LongConverter.CONVERSION = value must be an integer
| #javax.faces.convert.LongConverter.CONVERSION_detail = value must be a long integer
| javax.faces.convert.NumberConverter.CONVERSION = value must be a number
| javax.faces.convert.NumberConverter.CONVERSION_detail = value must be a number
| #javax.faces.convert.ShortConverter.CONVERSION = value must be an integer
| #javax.faces.convert.ShortConverter.CONVERSION_detail = value must be a short integer
|
and you can in8l them of course.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045187#4045187
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045187
19 years, 1 month
[JBoss Seam] - Seam and Identity.logout
by tony.herstell@gmail.com
Refers: http://www.icefaces.org/JForum/posts/list/0/4463.page#19798
I am invalidating a login (and that kills of some session scoped objects) good... but I think new ones are not being re-created for the new session (possibly as one has not been created yet).
Is it possible to force Seam, on Identity.logout to go to the index.html page so I can arrive at my seam app and have my new session object created for me?
anonymous wrote :
| It seems that if I just re-load the browser then I get past the problem.
|
| It's as if when I call the indentity.logout the session is destroyed, but a new one is not created... in fact the page is left with "old" data on it...
|
| So possibly; when Icefaces(or even seam); tries to access the session variables they are not there... (they are used on a page re-fresh of every page as they are in teh base template!)
|
| Refreshing the page, like coming to it the first time, causes my session objects to be created?
|
| I will post this on the seam forums and see what happens.
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045186#4045186
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045186
19 years, 1 month