This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 - textfield - required attribute doesn't work

 
marco pavone
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marco,

Can you please post your whole jsp Please?

Regards
Jatan

 
marco pavone
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.
You can find the required="true" at <s:textfield id="field1" .....
Thanks.

 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic