Creating the html forms itself is not a problem.
However i would like to have a dynamic amount of radio button sets. So to use this radio buttons within a loop with dynamic size.

So how to set the name of the radio button? For each set one value should be selected. So the name must be unique for each set.

And how do I get the values of all this into my Action class? I'd prefer having a hashmap there.

So the problem with the hashmap is not about the values which can be selected, but the form data being submitted.

Mario

Am 23.04.10 17:10, schrieb Martin Gainty:

jsp
  <s:set name="list" value="{1, 2, 3, 4, 5}"/>

  <s:radio list="%{#list}" name="list"/>

hth
martin
----------------------------------------------------------
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




Date: Fri, 23 Apr 2010 16:32:48 -0700
From: ma...@lipinski.tk
To: user@struts.apache.org
Subject: Re: Dynamic list of radio buttons

Hi,

thank you for your reply.
Taking your comments I ended with the following jsp code:

<s:form>
<s:iterator value="results">
        <s:property value="id" /><br />
        <s:property value="value" /><br />
        <s:property value="method" /><br />
        <s:property value="doc.title" /><br />
        <s:radio list="{1, 2, 3, 4, 5}" name="currentResult.rating" />
</s:iterator>
<s:submit />
</s:form>

Having for example two datasets in results, I can only select one radio
button (because the name has no dynamic component in the name).
I tried something like name="rating[%{id}]" but I fail to get these
parameters set in my Action class.

com.opensymphony.xwork2.ognl.OgnlValueStack  - Error setting expression
'rating[1]' with value '[Ljava.lang.String;@6ae7c6d1'
ognl.OgnlException: target is null for setProperty(null, "1",
[Ljava.lang.String;@6ae7c6d1)

How do the set-methods for this have to look like?

I'd prefer having a HashMap<Integer, Integer>  with the key set by the id
from the result and the value from the radio button.

Mario

Am 23.04.10 16:10, schrieb Martin Gainty:
<s:radio list="availableLevels" name="currentEmployee.level"/>

Date: Fri, 23 Apr 2010 15:55:52 -0700
From: ma...@lipinski.tk
To: user@struts.apache.org
Subject: Dynamic list of radio buttons

Hello,

I am wondering how to create a dynamic form containing a set of radio
buttons.

So I have an iterable list of database results. Any of the results
should be rated using radio buttons.

When the form is submitted I want to have a hashmap with an id as the
key and the value selected with the radio buttons as value.

How can I achieve this using struts2 and jsp?


Mario

                                        
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5



--
Mit freundlichen Grüßen

Mario Lipinski              Telefon: +49-531-1283333
Heinrich-Büssing-Ring 4     Mobil:   +49-171-4483626
38102 Braunschweig          Fax:     +49-3212-1132359
                            E-Mail:  ma...@lipinski.tk

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to