aspose file tools*
The moose likes Struts and the fly likes Struts2 - textfield - required attribute doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 - textfield - required attribute doesn Watch "Struts2 - textfield - required attribute doesn New topic
Author

Struts2 - textfield - required attribute doesn't work

marco pavone
Greenhorn

Joined: Sep 21, 2012
Posts: 3
Hi to all,
I use this code

and the following html code is generated:


Why I don't see the attribute required="required" in generated html?
Thanks to all.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi Macro,

requried attribute will just put the asterisk sign in form. It will provide the mark * to you form field.

It will generate the
when you set the required=true in the jsp.

Regards
Jatan
marco pavone
Greenhorn

Joined: Sep 21, 2012
Posts: 3
Thanks for your reply.
I checked out the generated html code and I don't see the span you mentioned or other * symbol, at least with "simple" struts theme.
The "required=true" seems to not have any effect...
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi Marco,

Can you please post your whole jsp Please?

Regards
Jatan

marco pavone
Greenhorn

Joined: Sep 21, 2012
Posts: 3
Sure.
You can find the required="true" at <s:textfield id="field1" .....
Thanks.

jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi Marco,

<s:textfield id="field1" name="registration.field1" cssClass="largeTextField" maxlength="20" required="true" title="test"/>
put the label attribute in your textfield.. like

. it will work and also you will be able to see the span and * in view source code.

Search in the apache site for the textfield and its attributes . you will get the answer.

Jatan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 - textfield - required attribute doesn't work