Discussion:
Radio buttons inside an iterate tag?
Wendy Smoak
2002-10-09 23:29:11 UTC
Permalink
I can't find an example of this one:

<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key" value="???" />
<bean:write name="resView" property="key" filter="true"/>
</logic:iterate>

What I really need for the radio button is something like:
<html:radio property="key" value="<% resView.getKey(); %>" />

Have I reached the point where I *must* use JSTL, or is there a way to get a
property from the 'current' bean as you iterate through and use it as the
value of a radio button?

(It's not that I don't want to use JSTL, I just haven't figured out Struts
yet, and I can only absorb so much at one time!)

If it helps, I'm presenting a "resolution page" after the user has typed in
a name. S/he will choose one of the names, and we'll go back to the
original form for more data entry.

Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Will Jaynes
2002-10-09 23:52:40 UTC
Permalink
Wendy,
Your example with the scriptlet is just what you need to do. This is a
case where scriptlets are still necessary. JSTL will be the way to do it
in the future, but you don't need to move to them before you are ready.
And to use JSTL now in a struts tag like html:radio you would need to
get the brand new struts-el tag library, which would be yet another
thing. So go ahead and use the scriptlet. They aren't so evil that they
can't be used judiciously.
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key" value="???" />
<bean:write name="resView" property="key" filter="true"/>
</logic:iterate>
<html:radio property="key" value="<% resView.getKey(); %>" />
Have I reached the point where I *must* use JSTL, or is there a way to get a
property from the 'current' bean as you iterate through and use it as the
value of a radio button?
(It's not that I don't want to use JSTL, I just haven't figured out Struts
yet, and I can only absorb so much at one time!)
If it helps, I'm presenting a "resolution page" after the user has typed in
a name. S/he will choose one of the names, and we'll go back to the
original form for more data entry.
Thanks,
John Owen
2002-10-10 13:58:40 UTC
Permalink
I think the body of the <html:radio> tag is the value, so just do this :

<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key">
<bean:write name="resView" property="key" filter="true"/>
</html:radio>
</logic:iterate>

----- Original Message -----
From: "Wendy Smoak" <***@asu.edu>
To: "'Struts Users Mailing List'" <struts-***@jakarta.apache.org>
Sent: Wednesday, October 09, 2002 6:29 PM
Subject: Radio buttons inside an iterate tag?
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key" value="???" />
<bean:write name="resView" property="key" filter="true"/>
</logic:iterate>
<html:radio property="key" value="<% resView.getKey(); %>" />
Have I reached the point where I *must* use JSTL, or is there a way to get a
property from the 'current' bean as you iterate through and use it as the
value of a radio button?
(It's not that I don't want to use JSTL, I just haven't figured out Struts
yet, and I can only absorb so much at one time!)
If it helps, I'm presenting a "resolution page" after the user has typed in
a name. S/he will choose one of the names, and we'll go back to the
original form for more data entry.
Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
John Owen
2002-10-10 14:24:57 UTC
Permalink
Also, I think you have to supply the name attribute in the <html:radio> tag.
----- Original Message -----
From: "John Owen" <***@hotmail.com>
To: "Struts Users Mailing List" <struts-***@jakarta.apache.org>
Sent: Thursday, October 10, 2002 8:58 AM
Subject: Re: Radio buttons inside an iterate tag?
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key">
<bean:write name="resView" property="key" filter="true"/>
</html:radio>
</logic:iterate>
----- Original Message -----
Sent: Wednesday, October 09, 2002 6:29 PM
Subject: Radio buttons inside an iterate tag?
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key" value="???" />
<bean:write name="resView" property="key" filter="true"/>
</logic:iterate>
<html:radio property="key" value="<% resView.getKey(); %>" />
Have I reached the point where I *must* use JSTL, or is there a way to
get
Post by Wendy Smoak
a
Post by Wendy Smoak
property from the 'current' bean as you iterate through and use it as the
value of a radio button?
(It's not that I don't want to use JSTL, I just haven't figured out Struts
yet, and I can only absorb so much at one time!)
If it helps, I'm presenting a "resolution page" after the user has typed
in
Post by Wendy Smoak
a name. S/he will choose one of the names, and we'll go back to the
original form for more data entry.
Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
--
<mailto:struts-user-***@jakarta.apache.org>
Wendy Smoak
2002-10-10 15:00:19 UTC
Permalink
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons" >
<html:radio property="key">
<bean:write name="resView" property="key" filter="true"/>
</html:radio>
</logic:iterate>
That didn't work:
According to the TLD attribute value is mandatory for tag radio

Back to the scriplet or JSTL approach-- I tried it yesterday and it didn't
seem that the resVew bean was immediately available. I'm guessing it gets
put into page scope, or else I have to <bean:define> in order to get to it.
(Wasn't this where TEI's came into play, once upon a time?)
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Wendy Smoak
2002-10-10 17:13:04 UTC
Permalink
Back to the scriptlet or JSTL approach
I'm still trying to get a property from a bean while iterating, and use it
as the value of a radio button:

<logic:iterate id="resView" name="foundPersons" >
<bean:write name="resView" property="key" filter="true"/>
<html:radio property="key" value="${resView.key}" /> <-- problem here
</logic:iterate>

Okay, what do I need to make ${resView.key} work? And am I even doing it
right? I'm getting "Cannot find bean under name
org.apache.struts.taglib.html.BEAN".

This is Tomcat 4.1.12, (just moved to it 20 minutes ago,) but I don't quite
understand if I should use JSTL or if there's a separate Struts expression
language. I've only been half-listening since I was on 3.3.1 and it didn't
apply...

Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Sri Sankaran
2002-10-10 18:03:41 UTC
Permalink
You *should* be able to do

<html:radio property="key" value="<%=resView.getKey()%>"/>

I am doing it in my application (yes, within an iteration). I would, in addition, set the type attribute for the <logic:iterate> to the fully qualified class name of the object in each iteration (resView).

Sri

-----Original Message-----
From: Wendy Smoak [mailto:***@asu.edu]
Sent: Thursday, October 10, 2002 1:13 PM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Back to the scriptlet or JSTL approach
I'm still trying to get a property from a bean while iterating, and use it as the value of a radio button:

<logic:iterate id="resView" name="foundPersons" >
<bean:write name="resView" property="key" filter="true"/>
<html:radio property="key" value="${resView.key}" /> <-- problem here
</logic:iterate>

Okay, what do I need to make ${resView.key} work? And am I even doing it right? I'm getting "Cannot find bean under name org.apache.struts.taglib.html.BEAN".

This is Tomcat 4.1.12, (just moved to it 20 minutes ago,) but I don't quite understand if I should use JSTL or if there's a separate Struts expression language. I've only been half-listening since I was on 3.3.1 and it didn't apply...

Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Karr, David
2002-10-10 18:11:31 UTC
Permalink
Post by Sri Sankaran
-----Original Message-----
Sent: Thursday, October 10, 2002 10:13 AM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Back to the scriptlet or JSTL approach
I'm still trying to get a property from a bean while
iterating, and use it
<logic:iterate id="resView" name="foundPersons" >
<bean:write name="resView" property="key" filter="true"/>
<html:radio property="key" value="${resView.key}" />
<-- problem here
</logic:iterate>
Okay, what do I need to make ${resView.key} work? And am I
even doing it
right? I'm getting "Cannot find bean under name
org.apache.struts.taglib.html.BEAN".
This is Tomcat 4.1.12, (just moved to it 20 minutes ago,) but
I don't quite
understand if I should use JSTL or if there's a separate
Struts expression
language. I've only been half-listening since I was on 3.3.1
When you get the "Cannot find bean ..." error message, it's hard to tell
WHICH bean it can't find. Do you know that there is a bean named
"foundPersons"?

This is where it's very helpful to execute this in a debugger, with the
Struts source code available. Once you have that set up, it's easier to
track down things like this.

Do you have valid "taglib" directives for both the Struts tag libraries, and
the JSTL?

These questions don't matter too much, as you're trying to use JSTL EL
references inside normal Struts tags. That won't work. However, if you get
the nightly build of Struts, you'll notice a new "contrib" library directory
named "struts-el". This contains a tag library which is derived from the
Struts tag library, which uses the JSTL EL engine for evaluating attribute
values, instead of using "rtexprvalue"s. This library was only recently
released (by me), so it's still only in the nightly build, and not even in a
beta release yet.
Wendy Smoak
2002-10-10 18:25:06 UTC
Permalink
Post by Karr, David
When you get the "Cannot find bean ..." error message, it's hard to tell
WHICH bean it can't find. Do you know that there is a bean named
"foundPersons"?
Yeah, for me, too. :) But yes, the foundPersons collection is there. The
page loads fine if I comment out the the <html:radio> tag. It has to be the
resView bean that I assume <logic:iterate> puts somewhere (page scope?) so
that the nested tags can "see" it. For some reason, it isn't visible to
that scriptlet.
Post by Karr, David
These questions don't matter too much, as you're trying to use JSTL EL
references inside normal Struts tags. That won't work. However, if you
get
Post by Karr, David
the nightly build of Struts, you'll notice a new "contrib" library
directory
Post by Karr, David
named "struts-el". This contains a tag library which is derived from the
Struts tag library, which uses the JSTL EL engine for evaluating attribute
values, instead of using "rtexprvalue"s. This library was only recently
released (by me), so it's still only in the nightly build, and not even in
a
Post by Karr, David
beta release yet.
The light begins to dawn. :) Thanks...
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Wendy Smoak
2002-10-10 18:26:19 UTC
Permalink
Post by Sri Sankaran
You *should* be able to do
<html:radio property="key" value="<%=resView.getKey()%>"/>
I am doing it in my application (yes, within an iteration).
I would, in addition, set the type attribute for the <logic:iterate>
to the fully qualified class name of the object in each iteration
(resView).

Okay, now I have:

<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio property="key" value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>

Same error. org.apache.jasper.JasperException: Cannot find bean under name
org.apache.struts.taglib.html.BEAN
(And it's definitely the <html:radio> tag, because if I comment it out, the
page loads fine without radio buttons.)

It seems to me that <logic:iterate> isn't putting that resView bean in a
place that the scriptlet can find it.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Kris Schneider
2002-10-10 19:11:48 UTC
Permalink
Assuming the form has a foundPerson property, I think you need something like
this:

<logic:iterate id="resView" name="foundPersons">
<html:radio property="foundPerson" value="<%= resView.getKey() %>"/>
<bean:write name="resView" property="key" filter="true"/>
</logic:iterate>

The foundPersons collection contains all the possible values for a certain form
property (foundPerson, in my example), right?
Post by Sri Sankaran
Post by Sri Sankaran
You *should* be able to do
<html:radio property="key" value="<%=resView.getKey()%>"/>
I am doing it in my application (yes, within an iteration).
I would, in addition, set the type attribute for the <logic:iterate>
to the fully qualified class name of the object in each iteration
(resView).
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio property="key" value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>
Same error. org.apache.jasper.JasperException: Cannot find bean under name
org.apache.struts.taglib.html.BEAN
(And it's definitely the <html:radio> tag, because if I comment it out, the
page loads fine without radio buttons.)
It seems to me that <logic:iterate> isn't putting that resView bean in a
place that the scriptlet can find it.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
--
Kris Schneider <mailto:***@dotech.com>
D.O.Tech <http://www.dotech.com/>
Sri Sankaran
2002-10-10 18:39:07 UTC
Permalink
I was going to suggest that something was amiss with your action mapping since the error message isn't reporting the name of the bean. However, I am puzzled by the fact that everything else works (when the <html:radio> is commented out).

You could be right about <logic:iterate> not make the id attribute available. But you'd think somebody else would have stumbled on it by now.

All my work with iterations has been with the <nested:iterate> tag. Following is a snippet from my application:

<nested:iterate id="anAddress"
type="com.sas.mis.qs.struts.bean.SiteAddressBean"
property="addresses">
<tr id="<%=anAddress.getSite()%>">
<td>
<nested:radio property="../site"
value="<%=anAddress.getSite()%>"/>

Thinks works like a charm. You *could* trying the <nested> tags and see if it fixes your problem. You don't have to have a nested structure in order to use the <nested> tags although that's where its strengths lie.

Sri

-----Original Message-----
From: Wendy Smoak [mailto:***@asu.edu]
Sent: Thursday, October 10, 2002 2:26 PM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Post by Sri Sankaran
You *should* be able to do
<html:radio property="key" value="<%=resView.getKey()%>"/>
I am doing it in my application (yes, within an iteration).
I would, in addition, set the type attribute for the <logic:iterate>
to the fully qualified class name of the object in each iteration
(resView).

Okay, now I have:

<logic:iterate id="resView" name="foundPersons" type="edu.asu.vpia.value.ResolutionView">
<html:radio property="key" value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>

Same error. org.apache.jasper.JasperException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
(And it's definitely the <html:radio> tag, because if I comment it out, the page loads fine without radio buttons.)

It seems to me that <logic:iterate> isn't putting that resView bean in a place that the scriptlet can find it.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Karr, David
2002-10-10 18:48:13 UTC
Permalink
Post by Sri Sankaran
-----Original Message-----
Sent: Thursday, October 10, 2002 11:26 AM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Post by Sri Sankaran
You *should* be able to do
<html:radio property="key" value="<%=resView.getKey()%>"/>
I am doing it in my application (yes, within an iteration).
I would, in addition, set the type attribute for the
<logic:iterate>
Post by Sri Sankaran
to the fully qualified class name of the object in each iteration
(resView).
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio property="key" value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>
Same error. org.apache.jasper.JasperException: Cannot find
bean under name
org.apache.struts.taglib.html.BEAN
(And it's definitely the <html:radio> tag, because if I
comment it out, the
page loads fine without radio buttons.)
I believe you will need the following attribute on your "html:radio"
element:

name="resView"

Without it, I believe it would assume the ActionForm bean for the page, and
not the "resView" bean.
Sri Sankaran
2002-10-10 18:50:59 UTC
Permalink
I think that's it. I glossed over that detail since <nested:iterate> takes care of that for you.

Sri

-----Original Message-----
From: Karr, David [mailto:***@attws.com]
Sent: Thursday, October 10, 2002 2:48 PM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Post by Sri Sankaran
-----Original Message-----
Sent: Thursday, October 10, 2002 11:26 AM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Post by Sri Sankaran
You *should* be able to do
<html:radio property="key" value="<%=resView.getKey()%>"/> I am
doing it in my application (yes, within an iteration).
I would, in addition, set the type attribute for the
<logic:iterate>
Post by Sri Sankaran
to the fully qualified class name of the object in each iteration
(resView).
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio property="key" value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>
Same error. org.apache.jasper.JasperException: Cannot find
bean under name
org.apache.struts.taglib.html.BEAN
(And it's definitely the <html:radio> tag, because if I
comment it out, the
page loads fine without radio buttons.)
I believe you will need the following attribute on your "html:radio"
element:

name="resView"

Without it, I believe it would assume the ActionForm bean for the page, and not the "resView" bean.

--
To unsubscribe, e-mail: <mailto:struts-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-***@jakarta.apache.org>
Brian Holzer
2002-10-10 18:51:15 UTC
Permalink
Hi Wendy,
Have you tried

<html:radio name="resView" property="key" value="Your scriplet from
before"/>

You need to specify name="resView" because this is the handle to each
object during the iterate.
Brian
Wendy Smoak 10/10/02 09:00am >>>
That didn't work:
According to the TLD attribute value is mandatory for tag radio

Back to the scriplet or JSTL approach-- I tried it yesterday and it
didn't
seem that the resVew bean was immediately available. I'm guessing it
gets
put into page scope, or else I have to in order to get to it.
(Wasn't this where TEI's came into play, once upon a time?)
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Wendy Smoak
2002-10-10 22:35:19 UTC
Permalink
Post by Brian Holzer
You need to specify name="resView" because this is the handle to each
object during the iterate.
Finally! This works:

<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio name="resView" property="key" value="<%=resView.getKey()%>"/>

It turns into:
<input type="radio" name="key" value="0123456">

Thanks to everyone who helped out on this one...
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Wendy Smoak
2002-10-11 18:39:05 UTC
Permalink
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio name="resView" property="key" value="<%=resView.getKey()%>"/>
<input type="radio" name="key" value="0123456">
Thought I'd follow up on this one since there was more to it. The radio
buttons were actually *all* getting "checked".
<input type="radio" name="key" value="0123456" checked="checked">

Apparently radio buttons are meant to display a pre-defined set of choices,
and the <html:radio> tag will pre-select one of them based on a property of
a bean. What I need is the ability to display a set of choices that I don't
know until right before the page is displayed.

I've got a Collection [foundPersons] of [ResolutionView] beans I'm iterating
through, doing one radio button *per bean*.

I ended up defining a getResolutionKey() method in my bean. It just returns
an empty String, which keeps the <html:radio> tag from selecting every
single radio button. (Of course the browser only showed the final one
selected, but I don't want *any* of them pre-selected.)

So now I have:
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio name="resView" property="resolutionKey"
value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>

And I get:
<input type="radio" name="resolutionKey" value="0143062"> 0143062

I think that's the best I can do at present, although I'll probably try to
get rid of the scriptlet one day.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Kris Schneider
2002-10-11 18:45:03 UTC
Permalink
Wendy,

This is what I was getting at in my previous reply. The property attribute of
the radio tag should correspond to a property of your form, not a property of
the beans in the collection you're iterating through.

By the way, 1.1 introduced an idName attribue on the radio tag that might be of
help...
Post by Wendy Smoak
Post by Wendy Smoak
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio name="resView" property="key" value="<%=resView.getKey()%>"/>
<input type="radio" name="key" value="0123456">
Thought I'd follow up on this one since there was more to it. The radio
buttons were actually *all* getting "checked".
<input type="radio" name="key" value="0123456" checked="checked">
Apparently radio buttons are meant to display a pre-defined set of choices,
and the <html:radio> tag will pre-select one of them based on a property of
a bean. What I need is the ability to display a set of choices that I don't
know until right before the page is displayed.
I've got a Collection [foundPersons] of [ResolutionView] beans I'm iterating
through, doing one radio button *per bean*.
I ended up defining a getResolutionKey() method in my bean. It just returns
an empty String, which keeps the <html:radio> tag from selecting every
single radio button. (Of course the browser only showed the final one
selected, but I don't want *any* of them pre-selected.)
<logic:iterate id="resView" name="foundPersons"
type="edu.asu.vpia.value.ResolutionView">
<html:radio name="resView" property="resolutionKey"
value="<%=resView.getKey()%>"/>
<bean:write name="resView" property="key" filter="true"/>
<input type="radio" name="resolutionKey" value="0143062"> 0143062
I think that's the best I can do at present, although I'll probably try to
get rid of the scriptlet one day.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
--
Kris Schneider <mailto:***@dotech.com>
D.O.Tech <http://www.dotech.com/>
Wendy Smoak
2002-10-11 18:56:33 UTC
Permalink
Post by Kris Schneider
This is what I was getting at in my previous reply. The property attribute
of
Post by Kris Schneider
the radio tag should correspond to a property of your form, not a property
of
Post by Kris Schneider
the beans in the collection you're iterating through.
But there *is* no form. To clarify, there is an html <form> tag, but NOT a
Struts <html:form> tag. So there is no ActionForm extension for this
particular form. All the resolution page does is present a list of choices,
and then [somehow] go back to where the user came from.

I tried to make a ResolutionForm [see other message about whether ever form
should have one] but it made things worse.
Post by Kris Schneider
By the way, 1.1 introduced an idName attribue on the radio tag that might
be of
Post by Kris Schneider
help...
Probably! I'll take a look. I still need to get the nightly build and try
out the expression language stuff.

Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Kris Schneider
2002-10-11 19:22:35 UTC
Permalink
Okaaay...if there's no html:form, why use html:radio? How 'bout just doing
something like:

<input type="radio" name="key" value='<bean:write name="resView"
property="key"/>'>

You said you don't want any radio buttons initially selected, bit here's a
snippet from the HTML 4.01 spec:

<quote>
If no radio button in a set sharing the same control name is initially "on",
user agent behavior for choosing which control is initially "on" is undefined.
Note. Since existing implementations handle this case differently, the current
specification differs from RFC 1866 ([RFC1866] section 8.1.2.4), which states:

At all times, exactly one of the radio buttons in a set is checked. If none of
the <INPUT> elements of a set of radio buttons specifies `CHECKED', then the
user agent must check the first radio button of the set initially.

Since user agent behavior differs, authors should ensure that in each set of
radio buttons that one is initially "on".
</quote>
Post by John Owen
Post by Kris Schneider
This is what I was getting at in my previous reply. The property
attribute
of
Post by Kris Schneider
the radio tag should correspond to a property of your form, not a
property
of
Post by Kris Schneider
the beans in the collection you're iterating through.
But there *is* no form. To clarify, there is an html <form> tag, but NOT a
Struts <html:form> tag. So there is no ActionForm extension for this
particular form. All the resolution page does is present a list of choices,
and then [somehow] go back to where the user came from.
I tried to make a ResolutionForm [see other message about whether ever form
should have one] but it made things worse.
Post by Kris Schneider
By the way, 1.1 introduced an idName attribue on the radio tag that might
be of
Post by Kris Schneider
help...
Probably! I'll take a look. I still need to get the nightly build and try
out the expression language stuff.
Thanks,
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
--
Kris Schneider <mailto:***@dotech.com>
D.O.Tech <http://www.dotech.com/>
Karr, David
2002-10-11 19:55:11 UTC
Permalink
Post by Sri Sankaran
-----Original Message-----
Sent: Friday, October 11, 2002 11:57 AM
To: 'Struts Users Mailing List'
Subject: RE: Radio buttons inside an iterate tag?
Post by Kris Schneider
This is what I was getting at in my previous reply. The
property attribute
of
Post by Kris Schneider
the radio tag should correspond to a property of your form,
not a property
of
Post by Kris Schneider
the beans in the collection you're iterating through.
But there *is* no form. To clarify, there is an html <form>
tag, but NOT a
Struts <html:form> tag. So there is no ActionForm extension for this
particular form. All the resolution page does is present a
list of choices,
and then [somehow] go back to where the user came from.
What he meant is that the name/property pair on your "radio" tag will likely
correspond to a bean and property that is NOT the one used to set your
"value" attribute. If the value of the "name/property" pair equals your
"value" attribute, then the button is checked. You will most likely have
all the radio buttons in a set use the same "name/property" pair, but have
different "value" values. Hopefully, only one of those "value" values will
equal the "name/property" value, so only one will be checked.
Wendy Smoak
2002-10-11 20:02:04 UTC
Permalink
Post by Kris Schneider
Okaaay...if there's no html:form, why use html:radio?
<input type="radio" name="key" value='<bean:write name="resView"
property="key"/>'>
'Cause... you didn't suggest it until now? Seriously, THANKS! I tend to
get a new toy and try to press ALL the buttons at once. ;) As usual, I was
making it more complicated than necessary. (I used double quotes rather
than your single ones... any reason you used single quotes? It confuses the
syntax highlighting in my editor, but it does work.)

And this means... the same trick should work in the <form> tag to set the
action! [Lunch interfered with trying that out.]
Post by Kris Schneider
You said you don't want any radio buttons initially selected, bit here's a
<quote>
Since user agent behavior differs, authors should ensure that in each set
of
Post by Kris Schneider
radio buttons that one is initially "on".
</quote>
Pfft. Which invalidates my method above, unless I jump through some hoops
to do something on the first iteration but not on subsequent passes. I
believe I'll just cross my fingers and let the browser handle it. It's not
fatal if one of them *is* pre-selected, but what I was seeing before is
*all* of them pre-selected with checked="checked" in the HTML. (The browser
was displaying the final button as selected.)

Many thanks for helping me hash this out.
--
Wendy Smoak
http://sourceforge.net/projects/unidbtags
Loading...