Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Michael Poznecki
[SOLVED] Dynamically create radio buttons?
16. Juli 2009 11:29
Antwort

Michael Poznecki

Rang: Expert

Nachrichten: 301

Eintrittsdatum: 10. Dezember 2008

Neue Beiträge

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?
16. Juli 2009 11:30
Antwort

Michael Poznecki

Rang: Expert

Nachrichten: 301

Eintrittsdatum: 10. Dezember 2008

Neue Beiträge

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?
28. September 2011 09:24
Antwort

Muhammad Asif

Rang: Junior Member

Nachrichten: 25

Eintrittsdatum: 11. April 2011

Neue Beiträge

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.