Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hiding form field labels

 
Sang Ts
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In <s:textfield> tag how can we disable the label attribute associated with struts2 form fields? Is it possible?
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What you are trying to achieve?

Regards
Jatan
 
Sang Ts
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you for the reply.

When adding a struts control say a text field to a form, even if we are not giving the Label attribute, a label column (a new TD ) is added for that label.

We want to avoid this Label auto generation. We want to give the Label of the control explicity, directly in HTML itself.
Actually we want to avoid the new TD generation, this may badly affect our layout and design.

When adding the following line in jsp page

<form id="frm">
<table>
<tr>
<td>
<s:textfield name="userName" ></s:textfield>
</td>
</tr>
<table>
</form>

it will renders as

<form id="frm">
<table>
<tr>
<td>
<label for="frm_userName" class="label"> </label>
</td>
<td>
<input type="text" name="userName" value="" id="frm_userName">
</td>
</tr>
<table>
</form>

Thanks
Sang
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according to what ever you coded here

<form id="frm">
<table>
<tr>
<td>
<s:textfield name="userName" ></s:textfield>
</td>
</tr>
<table>
</form>

will not generate any label for particular input field because you have not specified any lable="FooBar" for it and if it is generated it might be because some where some how you are setting Key for that element. it will have auto key if your using JQuery some where for that field
 
Sang Ts
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you for the reply.
When I added theme as "simple" in my form tag i got the textfield without extra column for label.
Thanks
Sang TS
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic