Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying radio button in <tr> (Next Line) in Struts 2

 
Abdul Mujeeb Md
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How do we display the Radio buttons aligned vertically using Struts 2 Tag. The default implementation populates it in a horizontal format.

Thanks.
 
Ajit Amitav Das
Ranch Hand
Posts: 49
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts2 uses FTL (freemarker template) internally to render components.

In your case for radio buttons it uses "radiomap.ftl" for generating the HTML code.

This file will be present in struts default jar file, extract this file and modify accordingly as per your customization put a break tag after each iteration of the collection items.

Create a folder named as theme under your webapp project and create a folder named as XYZ(example : radiovertical) under that theme folder and put your modifed radiomap.ftl file under XYZ folder.

radiomap.ftl is a big file to mention so just putting code snippet how to do this: modifed code are mentioned in bold font.

<@s.iterator value="parameters.list">
<#if parameters.listKey??>
<#assign itemKey = stack.findValue(parameters.listKey)/>

// rest of the code which I have deleted for wrapping it in a small conversation.

<label for="${parameters.id?html}${itemKeyStr?html}"><#rt/>
${itemValue}<#t/>
</label>
<br /><br />
</@s.iterator>


After all these changes use your theme (XYZ ) for struts radio tag as follows:

<s:radio theme="radioVertical" .....rest of the things here />

This will create each item in a new line.

Hope this will give you some valid information and technique to use/customize struts tag.
 
Abdul Mujeeb Md
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ajit. That works
 
John Sears
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm I ran into this problem too. Is there no way to do it declaratively without creating additional file structure? Ideally there ought to be an easier way to get vertical radio lists...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic