You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Fiona Thorne <ft...@tradingpost.com.au> on 2001/05/29 07:54:28 UTC
Radio Buttons With Generated Values
HI! I am pretty new to struts and I'm working my way through the different
types
of controls (select, multiboxes, etc).
I am having rouble generating a list of radio buttons.
I have a Map (actual a Properties object but its returned as a Map) which
contains
two entries:
"DEBIT", "Debit my credit card"
"INVOICE", "Send me an invoice".
The Map object is available in my JSP page as the bean paymentTypeData:
<jsp:useBean id="paymentTypeData" scope="page"
class="au.com.tp.placead.PaymentTypeData"/>
It is also accessable via another bean paymentData using the getter method
getPaymentType():
<jsp:useBean id="paymentData" scope="page"
class="au.com.tp.placead.PaymentData"/>
I am trying to generate the following HTML:
<input type="radio" name="useCC" value="DEBIT">Debit my credit card<BR>
<input type="radio" name="useCC" value="INVOICE">Send me an invoice<BR>
The closest I can get is (some spacing removed)
<input type="radio" name="useCC" value="fred">INVOICE
Debit my credit card<BR>
<input type="radio" name="useCC" value="fred">DEBIT
Send me an invoice<BR>
by using the following JSP:
<logic:iterate name="paymentData" property="paymentType" id="payment_entry">
<html:radio property="useCC" value = "fred">
<bean:write name="payment_entry" property="key"/>
</html:radio>
<bean:write name="payment_entry" property="value" filter=false/><BR>
</logic:iterate>
I've had to put the 'value="fred"' in there, as value is required. Removing
it gives "required attribute `value' missing from `html:radio' "
Any suggestions about how I set dynamic values for "value"?
Fiona
_________________________________________________________
Fiona Thorne
Trading Post Australia Pty Limited phone 02 9954 8200
L5, 100 Mount St, North Sydney fax 02 9954 8250
NSW Australia 2065 Australia +61
http://www.tradingpost.com.au fthorne@tradingpost.com.au
_________________________________________________________
When life hands you scraps, make quilts.....
_________________________________________________________
Re: Radio Buttons With Generated Values
Posted by Martin Cooper <ma...@tumbleweed.com>.
I think you'll have to resort to using a JSP expression, like this:
<logic:iterate name="paymentData" property="paymentType" id="payment_entry">
<bean:define id="key" name="payment_entry" property="key"
type="java.lang.String"/>
<html:radio property="useCC" value="<%= key %>">
<bean:write name="payment_entry" property="value" filter="false"/><BR>
</html:radio>
</logic:iterate>
Hope this helps.
--
Martin Cooper
At 10:54 PM 5/28/01, Fiona Thorne wrote:
>HI! I am pretty new to struts and I'm working my way through the different
>types
>of controls (select, multiboxes, etc).
>
>I am having rouble generating a list of radio buttons.
>
>I have a Map (actual a Properties object but its returned as a Map) which
>contains
>two entries:
>"DEBIT", "Debit my credit card"
>"INVOICE", "Send me an invoice".
>
>The Map object is available in my JSP page as the bean paymentTypeData:
><jsp:useBean id="paymentTypeData" scope="page"
>class="au.com.tp.placead.PaymentTypeData"/>
>
>It is also accessable via another bean paymentData using the getter method
>getPaymentType():
><jsp:useBean id="paymentData" scope="page"
>class="au.com.tp.placead.PaymentData"/>
>
>I am trying to generate the following HTML:
> <input type="radio" name="useCC" value="DEBIT">Debit my credit card<BR>
> <input type="radio" name="useCC" value="INVOICE">Send me an invoice<BR>
>
>The closest I can get is (some spacing removed)
>
> <input type="radio" name="useCC" value="fred">INVOICE
>Debit my credit card<BR>
> <input type="radio" name="useCC" value="fred">DEBIT
>Send me an invoice<BR>
>
>by using the following JSP:
>
><logic:iterate name="paymentData" property="paymentType" id="payment_entry">
> <html:radio property="useCC" value = "fred">
> <bean:write name="payment_entry" property="key"/>
> </html:radio>
><bean:write name="payment_entry" property="value" filter=false/><BR>
></logic:iterate>
>
>I've had to put the 'value="fred"' in there, as value is required.
>Removing it gives "required attribute `value' missing from `html:radio' "
>
>Any suggestions about how I set dynamic values for "value"?
>
>Fiona
>
>_________________________________________________________
>Fiona Thorne
>Trading Post Australia Pty Limited phone 02 9954 8200
>L5, 100 Mount St, North Sydney fax 02 9954 8250
>NSW Australia 2065 Australia +61
>http://www.tradingpost.com.au fthorne@tradingpost.com.au
>_________________________________________________________
>When life hands you scraps, make quilts.....
>_________________________________________________________