Re: Error Message for Struts Validation

2004-10-01 Thread Caroline Jen
Thanks for your help.  The explanation is very clear.
--- Matt Bathje <[EMAIL PROTECTED]> wrote:

> I've never used the  attribute myself, but I
> think when you do, you 
> need to specify the key, and a name attribute for
> which validation the 
> message applies to. So in your case it would be:
> 
> 
> 
> You may also need to specify a bundle and resource
> attribute, but I 
> don't think so in your case.
> 
> The error message you are seeing (null is required)
> is from the default 
> error message. When you use the default error
> message, you need to 
> specify replacement values for the error message
> template. If you look 
> in your application.properties, you should have a
> bunch of errors. 
> lines, for each standard validator. For example, you
> should have a line 
> like:
> 
> errors.required={0} is required.
> 
> for the required validator. The {0} is what needs a
> replacement. To 
> define it in your validator, you use:
> 
> 
> OR (for struts 1.2.x)
> 
> 
> In these cases though, request.page should be
> defined in 
> application.properties as:
> 
> request.page=Page
> 
> then, when the error prints, it will print as "Page
> is required."
> 
> For me at least, this is a lot more handy than using
> , because you 
> can use the same label to print out the prompt and
> the error message.
> 
> Hopefully I explained this well enough...
> 
> Matt
> 
> 
> 
> Caroline Jen wrote:
> 
> > I use the validation.xml to validate the
> properties in
> > my form bean.  The validation works; but, the
> error
> > messages do not work as I expected.
> > 
> > While I have customized error messages prepared,
> the
> > error message displayed in the browser window for
> my
> > intentional violation are like:
> > . null is required
> > . null is required
> > 
> > I also wonder how to show error messages if there
> are
> > more than one validation check for a certain
> property.
> >  For example, depends="required,mask".
> > 
> > For example, in my validation.xml, I have:
> > [CODE]
> >   
> >   > property="document"
> > depends="required">
> >
> >  
> >   > property="title"
> > depends="required">
> >
> >  
> >   
> > [/CODE]
> > 
> > In my web.xml, I have:
> > [CODE]
> >   
> > application
> >
> resources.application
> >   
> > [/CODE]
> > 
> > and the application.properties file is in the
> >
>
C:\jakarta-tomcat-5.0.27\webapps\AppName\WEB-INF\classes\resources
> > directory.
> > 
> > In the application.properties, I have:
> > 
> > [CODE]
> > request.page=The requested page is not provided.
> > insert.tile=The title of the requested page must
> not
> > be left blank.
> > [/CODE]
> > 
> > 
> > 
> > ___
> > Do you Yahoo!?
> > Declare Yourself - Register online to vote today!
> > http://vote.yahoo.com
> > 
> >
>
-
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Error Message for Struts Validation

2004-09-30 Thread Matt Bathje
I've never used the  attribute myself, but I think when you do, you 
need to specify the key, and a name attribute for which validation the 
message applies to. So in your case it would be:


You may also need to specify a bundle and resource attribute, but I 
don't think so in your case.

The error message you are seeing (null is required) is from the default 
error message. When you use the default error message, you need to 
specify replacement values for the error message template. If you look 
in your application.properties, you should have a bunch of errors. 
lines, for each standard validator. For example, you should have a line 
like:

errors.required={0} is required.
for the required validator. The {0} is what needs a replacement. To 
define it in your validator, you use:


OR (for struts 1.2.x)

In these cases though, request.page should be defined in 
application.properties as:

request.page=Page
then, when the error prints, it will print as "Page is required."
For me at least, this is a lot more handy than using , because you 
can use the same label to print out the prompt and the error message.

Hopefully I explained this well enough...
Matt

Caroline Jen wrote:
I use the validation.xml to validate the properties in
my form bean.  The validation works; but, the error
messages do not work as I expected.
While I have customized error messages prepared, the
error message displayed in the browser window for my
intentional violation are like:
. null is required
. null is required
I also wonder how to show error messages if there are
more than one validation check for a certain property.
 For example, depends="required,mask".
For example, in my validation.xml, I have:
[CODE]
  
 
   
 
 
   
 
  
[/CODE]
In my web.xml, I have:
[CODE]
  
application
resources.application
  
[/CODE]
and the application.properties file is in the
C:\jakarta-tomcat-5.0.27\webapps\AppName\WEB-INF\classes\resources
directory.
In the application.properties, I have:
[CODE]
request.page=The requested page is not provided.
insert.tile=The title of the requested page must not
be left blank.
[/CODE]

___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Error Message for Struts Validation

2004-09-30 Thread Caroline Jen
I use the validation.xml to validate the properties in
my form bean.  The validation works; but, the error
messages do not work as I expected.

While I have customized error messages prepared, the
error message displayed in the browser window for my
intentional violation are like:
. null is required
. null is required

I also wonder how to show error messages if there are
more than one validation check for a certain property.
 For example, depends="required,mask".

For example, in my validation.xml, I have:
[CODE]
  
 
   
 
 
   
 
  
[/CODE]

In my web.xml, I have:
[CODE]
  
application
resources.application
  
[/CODE]

and the application.properties file is in the
C:\jakarta-tomcat-5.0.27\webapps\AppName\WEB-INF\classes\resources
directory.

In the application.properties, I have:

[CODE]
request.page=The requested page is not provided.
insert.tile=The title of the requested page must not
be left blank.
[/CODE]



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]