Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Michael Poznecki
[SOLVED] Dynamically create radio buttons?
July 16, 2009 11:29 AM
Answer

Michael Poznecki

Rank: Expert

Posts: 301

Join Date: December 10, 2008

Recent Posts

Hello all,
I am trying to create a unknown number of radio buttons on my struts jsp page.

Here is what I was trying:
 1
 2       Map<String,String> choices;
 3                              
 4     choices = new LinkedHashMap<String,String>();
 5     String[] choices_data = {"AA", "BB", "CC", "DD", "EE", "FF", "GG" };
 6         for (int i=1; i <= choices_data.length; ++i) {
 7               choices.put(Integer.toString(i), choices_data[i-1]);
 8         }
 9
10
11                              
12    %>
13    <c:forEach var='item' items="${choices}">
14              <input type="radio" name="rb" value="${item.key}" /> ${item.value}
15    </c:forEach>


But nothing shows up on my page. Can anyone help?

Thanks,
Michael
Michael Poznecki
RE: [SOLVED] Dynamically create radio buttons?
July 16, 2009 11:30 AM
Answer

Michael Poznecki

Rank: Expert

Posts: 301

Join Date: December 10, 2008

Recent Posts

Thanks to my good friend Albert J Carter-Corbin!!!

I just need to add this line of code to help with variable scope:
1pageContext.setAttribute( "choices", choices );
Muhammad Asif
RE: [SOLVED] Dynamically create radio buttons?
September 28, 2011 9:24 AM
Answer

Muhammad Asif

Rank: New Member

Posts: 24

Join Date: April 11, 2011

Recent Posts

As you have worked with radio buttons, can you please tell how to place the radio buttons horizontally using <aui:input type="radio" /> tag. Thanks in advance.