This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes Hiding form field labels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Hiding form field labels" Watch "Hiding form field labels" New topic
Author

Hiding form field labels

Sang Ts
Greenhorn

Joined: Oct 08, 2012
Posts: 4
In <s:textfield> tag how can we disable the label attribute associated with struts2 form fields? Is it possible?
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi,

What you are trying to achieve?

Regards
Jatan
Sang Ts
Greenhorn

Joined: Oct 08, 2012
Posts: 4
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

Joined: Jul 17, 2012
Posts: 94

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


Learning some thing New Every Day
Sang Ts
Greenhorn

Joined: Oct 08, 2012
Posts: 4
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
 
GeeCON Prague 2014
 
subject: Hiding form field labels