wood burning stoves 2.0*
The moose likes Struts and the fly likes Displaying radio button in <tr> (Next Line) in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Displaying radio button in <tr> (Next Line) in Struts 2" Watch "Displaying radio button in <tr> (Next Line) in Struts 2" New topic
Author

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

Abdul Mujeeb Md
Greenhorn

Joined: Aug 25, 2008
Posts: 26
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

Joined: Dec 14, 2005
Posts: 49
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.


Warm Regards<br />Ajit Amitav Das<br />SCJP 1.5
Abdul Mujeeb Md
Greenhorn

Joined: Aug 25, 2008
Posts: 26
Thanks Ajit. That works
John Sears
Greenhorn

Joined: Sep 15, 2009
Posts: 14
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying radio button in <tr> (Next Line) in Struts 2
 
Similar Threads
Struts interview questions
Action class in Struts
Struts 2 - disable a checkboxlist using javascript
WA #1.....word association
Struts2 radio button allignment