You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bhaarat Sharma <bh...@gmail.com> on 2009/04/19 23:04:25 UTC

Struts2 Validation not working with theme simple

I have a very weird error.

I am trying to do a very simple basic validation like this example:
http://struts.apache.org/2.x/docs/basic-validation.html

However, If i have the following line in my struts.properties then the
validation stops happening and I do not see any errors.
struts.ui.theme=simple

I spent a very long time in researching which line in my
struts.properties file is causing this error.

Has someone seen something like this before? what is the best way to
resolve this??

Thanks!

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


Re: Struts2 Validation not working with theme simple

Posted by Dave Newton <ne...@yahoo.com>.
Bhaarat Sharma wrote:
> At this time I cant afford to change the theme of the site.  Because
> that breaks the html on a lot of pages and would require a lot of
> effort to correct those pages.

Changing to show field error messages by hand would most likely entail 
significantly more work.

>> show field error messages by hand (if you want the messages near the fields),
> 
> how can i do this? do you mean, by using field validators like on this
> link? http://struts.apache.org/2.x/docs/using-field-validators.htmls

How are you doing validation now?

In any case, I meant showing field error messages by hand by checking 
the field errors map for specific field names, in the HTML/JSP, instead 
of having it done by the theme.

Seriously--consider modifying the simple theme (creating your own theme 
based on the simple theme) and adding the error message bits of one of 
the themes that includes them. Otherwise you'll be adding either a chunk 
of JSP to check for field errors, using a custom tag to encapsulate it 
somehow, or something fairly similar.

How is it that the project got so far along that changing the theme is 
too much work and nobody noticed that validation messages weren't being 
displayed?

Dave


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


Re: Struts2 Validation not working with theme simple

Posted by Dave Newton <ne...@yahoo.com>.
Bhaarat Sharma wrote:
> thanks dave!
> 
> <s:fielderror/> worked fine.  I was trying too many things so got confused.
> 
> I have one further question regarding validation.  Is it possible to
> validate a text field only when certain strings are selected from the
> multiple drop down box.
> 
> Basically I want to make the text feild required only when some
> strings are selected from the multiple drop down box, which is in the
> same form as the text field.  Can this be done via struts2 validation
> or do I have to write a custom validator for this?

I'd expect it could be handled with an expression validator; whether or 
not this is the cleanest solution is arguable. Once validation gets more 
complicated than a single expression or two doing it in Java may end up 
being easier to understand and maintain. There's no reason declarative 
and programmatic validation can't be combined.

Dave


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


Re: Struts2 Validation not working with theme simple

Posted by Bhaarat Sharma <bh...@gmail.com>.
thanks dave!

<s:fielderror/> worked fine.  I was trying too many things so got confused.

I have one further question regarding validation.  Is it possible to
validate a text field only when certain strings are selected from the
multiple drop down box.

Basically I want to make the text feild required only when some
strings are selected from the multiple drop down box, which is in the
same form as the text field.  Can this be done via struts2 validation
or do I have to write a custom validator for this?

Thanks!

On 4/19/09, Dave Newton <ne...@yahoo.com> wrote:
> Bhaarat Sharma wrote:
>> by the way. I can do without having errors right beside the textfield.
>>  I can have them grouped up top
>
> Are you saying the <s:fielderror/> tag doesn't render field errors in
> the "simple" theme? The template file sure makes it look like it does.
>
> Dave
>
>
> ---------------------------------------------------------------------
> 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


Re: Struts2 Validation not working with theme simple

Posted by Dave Newton <ne...@yahoo.com>.
Bhaarat Sharma wrote:
> by the way. I can do without having errors right beside the textfield.
>  I can have them grouped up top

Are you saying the <s:fielderror/> tag doesn't render field errors in 
the "simple" theme? The template file sure makes it look like it does.

Dave


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


Re: Struts2 Validation not working with theme simple

Posted by Bhaarat Sharma <bh...@gmail.com>.
by the way. I can do without having errors right beside the textfield.
 I can have them grouped up top

On 4/19/09, Bhaarat Sharma <bh...@gmail.com> wrote:
> Stop using the "simple" theme.
>
> The "simple" theme tags don't display error messages--they're simple.
> You'll either need to switch themes, show field error messages by hand
> (if you want the messages near the fields), or modify/extend/create a
> theme to emit the HTML you want.
>
> At this time I cant afford to change the theme of the site.  Because
> that breaks the html on a lot of pages and would require a lot of
> effort to correct those pages.
>
>>show field error messages by hand (if you want the messages near the
>> fields),
>
> how can i do this? do you mean, by using field validators like on this
> link? http://struts.apache.org/2.x/docs/using-field-validators.htmls
>
> Appreciate your help
>
>
> On 4/19/09, Dave Newton <ne...@yahoo.com> wrote:
>> Bhaarat Sharma wrote:
>>> However, If i have the following line in my struts.properties then the
>>> validation stops happening and I do not see any errors.
>>> struts.ui.theme=simple
>>
>> Technically, the validation does not stop happening.
>>
>>> Has someone seen something like this before?
>>
>> Yes, anybody using the "simple" theme.
>>
>>> what is the best way to resolve this??
>>
>> Stop using the "simple" theme.
>>
>> The "simple" theme tags don't display error messages--they're simple.
>> You'll either need to switch themes, show field error messages by hand
>> (if you want the messages near the fields), or modify/extend/create a
>> theme to emit the HTML you want.
>>
>> Dave
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: Struts2 Validation not working with theme simple

Posted by Bhaarat Sharma <bh...@gmail.com>.
Stop using the "simple" theme.

The "simple" theme tags don't display error messages--they're simple.
You'll either need to switch themes, show field error messages by hand
(if you want the messages near the fields), or modify/extend/create a
theme to emit the HTML you want.

At this time I cant afford to change the theme of the site.  Because
that breaks the html on a lot of pages and would require a lot of
effort to correct those pages.

>show field error messages by hand (if you want the messages near the fields),

how can i do this? do you mean, by using field validators like on this
link? http://struts.apache.org/2.x/docs/using-field-validators.htmls

Appreciate your help


On 4/19/09, Dave Newton <ne...@yahoo.com> wrote:
> Bhaarat Sharma wrote:
>> However, If i have the following line in my struts.properties then the
>> validation stops happening and I do not see any errors.
>> struts.ui.theme=simple
>
> Technically, the validation does not stop happening.
>
>> Has someone seen something like this before?
>
> Yes, anybody using the "simple" theme.
>
>> what is the best way to resolve this??
>
> Stop using the "simple" theme.
>
> The "simple" theme tags don't display error messages--they're simple.
> You'll either need to switch themes, show field error messages by hand
> (if you want the messages near the fields), or modify/extend/create a
> theme to emit the HTML you want.
>
> Dave
>
>
> ---------------------------------------------------------------------
> 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


Re: Struts2 Validation not working with theme simple

Posted by Dave Newton <ne...@yahoo.com>.
Bhaarat Sharma wrote:
> However, If i have the following line in my struts.properties then the
> validation stops happening and I do not see any errors.
> struts.ui.theme=simple

Technically, the validation does not stop happening.

> Has someone seen something like this before?

Yes, anybody using the "simple" theme.

> what is the best way to resolve this??

Stop using the "simple" theme.

The "simple" theme tags don't display error messages--they're simple. 
You'll either need to switch themes, show field error messages by hand 
(if you want the messages near the fields), or modify/extend/create a 
theme to emit the HTML you want.

Dave


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