struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albrecht Leiprecht" <aleipre...@t-online.de>
Subject RE: Validator...the 1001st question...
Date Wed, 10 Aug 2005 19:54:09 GMT
http://java.sun.com/developer/Books/javaprogramming/struts/struts_chptr_12.p
df

says :

12.4.3 Custom validator messages
A field can also specify a custom validation message to use instead of the
default. This often happens when the mask validator is being used, so you
can explain what pattern the regular expression expects. The key for the
message is given in a msg element. Since more than one validator may be used
by a field, the name of the validator is included as the msg element's name
attribute...


(for all others like me using old mails for research)


-----Original Message-----
From: Duane Rosengartner [mailto:DRosengartner@excentus.com] 
Sent: Wednesday, August 10, 2005 9:39 PM
To: Struts Users Mailing List; albi@leiprecht.de
Subject: RE: Validator...the 1001st question...

 Based on the following...
<field property="codeType" depends="required, maxlength">
                <msg name="required" key="errors.required" />
                <msg name="maxlength" key="errors.maxlength"/>
				<arg0 key="Code Type" resource="false"/>
                <arg1 name="maxlength" key="${var:maxlength}"
resource="false"/>
				<var>
					<var-name>maxlength</var-name>
					<var-value>20</var-value>
				</var>
            </field>

Try this in your own...
Change:  <msg name="testmsg" 
To:      <msg name="salutation" 

-----Original Message-----
From: Albrecht Leiprecht [mailto:aleiprecht@t-online.de] 
Sent: Wednesday, August 10, 2005 2:23 PM
To: 'Struts Users Mailing List'
Subject: Validator...the 1001st question...

Hi all,

I'm curious ... shouldn't it be possible to override the default error
message assigned to a validator rule ?

Here's the example:


validator.xml

[...]
<field depends="validwhen" property="salutation">
	<msg name="testmsg" key="error.saluation.makechoice"/>
	<arg key="label.salutation" position="0"/>
	<var>
  	<var-name>test</var-name>
  	<var-value>(*this* != "u")</var-value>
	</var>
</field>
[...]




validator-rules.xml

[...]
<validator name="validwhen"
	msg="errors.required"
      classname="org.apache.struts.validator.validwhen.ValidWhen"
      	method="validateValidWhen"
          	methodParams="java.lang.Object,
          		org.apache.commons.validator.ValidatorAction,
            	org.apache.commons.validator.Field,
            	org.apache.struts.action.ActionMessages,
            	org.apache.commons.validator.Validator,
            	javax.servlet.http.HttpServletRequest"/>
[...]

I understand, that the "errors.required" is the default msg. And thats
exactly what gets shown in case of an error. Am I stupid or shouldn't it
show "error.saluation.makechoice" instead ??

scratching his head
albi



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message