wureka
wureka

Reputation: 865

When using <s:select /> tag in Struts2, how to make colon disappear?

I have a problem when using UI tags (ex: <s:select />) in Struts.

I use the default theme in a form (theme='xhtml')

CASE 1

When using

<s:select label="FIELD1" ....../>

Struts2 will generate the HTML code shown below (I skipped the non-important portions)

<table>
  <tr>
    <td>FIELD1:</td>
    <td> <select ...... > </td>
  </tr>
</table>

CASE2

When using

<s:select label='' .....>

the generated HTML code is shown below:

<table>
  <tr>
    <td>:</td>
    <td> <select ...... > </td>
  </tr>
</table>

In the HTML code generated by Struts2, you still see a colon in the label field in table.

CASE3

When using

<s:select  .....>

If I do not use a label attribute, Struts2 will generate the HTML code shown below:

<table>
  <tr>
    <td></td>
    <td> <select ...... > </td>
  </tr>
</table>

In the HTML code generated by Struts2, you will see the label text is completely empty.

What I wish is, I set the attribute label='', and the label text in the HTML code generated by Struts2 is empty (no colon).

How do I do this?

Upvotes: 0

Views: 3624

Answers (2)

James Jithin
James Jithin

Reputation: 10555

Use the labelSeparator attribute to empty string and your requirement would be satisfied. Please refer the document for other attribute references for <s:select>:

http://struts.apache.org/2.x/docs/select.html

Upvotes: 1

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

This is due to the xhtml theme which you are using and based on that Struts2 tags are generating the HTML output for you.

here is what happening inside Struts2 free marker template which is being used to generate the HTML output.

${parameters.labelseparator?default(":")?html}<#t/>

so what happening when you have no labelseparator it is using default seperator which Struts2 internally using :

So either you should provide labelSeparator as said by James and for better control of the output use simple theme and defined/design page as per your choice.

Upvotes: 0

Related Questions