You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Reynolds <ji...@gmail.com> on 2006/02/01 21:46:24 UTC

html:radio headaches

I am having issues working with the html:radio tag.

First off: I have  simple bean which extends ActionForm. In my
business logic I create DTO objects and stuff them into the actionform
into a arrayList through a setter. The DTO has a getName method in it.

In my view, I am iterating over like so, and all is GOOD. It spills
out what I want:

     <logic:iterate id="sb" name="abcForm" property="daList"
indexId="index" offset='5'>
    <bean:write name="sb" property="name" />
   </logic:iterate>


According to the Struts Cookbook I then do this to get a radio button:

    <logic:iterate id="sb" name="abcForm" property="daList"
indexId="index" offset='5'>
   <html:radio property="name" idName="sb" value="name" />
    <bean:write name="sb" property="name" />
   </logic:iterate>

Whenever I do this with idName it complains that it cannot find the
getter for name, even through I am printing it out above with the
bean:write tag????
And if I just use name, then it prints out the value as a string and
does not interpret it.

I have never been able to get this to work correctly inside a logic:iterate tag?

Anyone .... ever pull this off?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:radio headaches

Posted by Laurie Harper <la...@holoweb.net>.
Jim Reynolds wrote:
> I am having issues working with the html:radio tag.
> 
> First off: I have  simple bean which extends ActionForm. In my
> business logic I create DTO objects and stuff them into the actionform
> into a arrayList through a setter. The DTO has a getName method in it.
> 
> In my view, I am iterating over like so, and all is GOOD. It spills
> out what I want:
> 
>      <logic:iterate id="sb" name="abcForm" property="daList"
> indexId="index" offset='5'>
>     <bean:write name="sb" property="name" />
>    </logic:iterate>
> 
> 
> According to the Struts Cookbook I then do this to get a radio button:
> 
>     <logic:iterate id="sb" name="abcForm" property="daList"
> indexId="index" offset='5'>
>    <html:radio property="name" idName="sb" value="name" />
>     <bean:write name="sb" property="name" />
>    </logic:iterate>
> 
> Whenever I do this with idName it complains that it cannot find the
> getter for name, even through I am printing it out above with the
> bean:write tag????
> And if I just use name, then it prints out the value as a string and
> does not interpret it.
> 
> I have never been able to get this to work correctly inside a logic:iterate tag?
> 
> Anyone .... ever pull this off?

Hmm, I've never used idName. My guess is that the problem is the 
property attribute, however. With what you have, you're saying that the 
radio button should be tied to abcForm.name but get its value from 
sb.name. I'm guessing your form bean doesn't have [gs]etName methods?

Try removing the property attribute, or changing its value to something 
spurious, and see what difference that makes.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:radio headaches

Posted by Michael Jouravlev <jm...@gmail.com>.
On 2/1/06, Jim Reynolds <ji...@gmail.com> wrote:
> I am having issues working with the html:radio tag.
>
> First off: I have  simple bean which extends ActionForm. In my
> business logic I create DTO objects and stuff them into the actionform
> into a arrayList through a setter. The DTO has a getName method in it.
>
> In my view, I am iterating over like so, and all is GOOD. It spills
> out what I want:
>
>      <logic:iterate id="sb" name="abcForm" property="daList"
> indexId="index" offset='5'>
>     <bean:write name="sb" property="name" />
>    </logic:iterate>
>
>
> According to the Struts Cookbook I then do this to get a radio button:
>
> <logic:iterate id="sb" name="abcForm" property="daList" indexId="index" offset='5'>
>   <html:radio property="name" idName="sb" value="name" />
>   <bean:write name="sb" property="name" />
> </logic:iterate>
>
> Whenever I do this with idName it complains that it cannot find the
> getter for name, even through I am printing it out above with the
> bean:write tag????
> And if I just use name, then it prints out the value as a string and
> does not interpret it.
>
> I have never been able to get this to work correctly inside a logic:iterate tag?
>
> Anyone .... ever pull this off?

In this:

<logic:iterate id="sb" name="abcForm" property="daList"
indexId="index" offset='5'>
  <bean:write name="sb" property="name" />
</logic:iterate>

1) you select absForm.daList.get(i) ==> sb, where i = 5..n
2) you write sb.name

In this:

<logic:iterate id="sb" name="abcForm" property="daList"
indexId="index" offset='5'>
  <html:radio property="name" idName="sb" value="name" />
  <bean:write name="sb" property="name" />
</logic:iterate>

1) you select absForm.daList.get(i) ==> sb, where i = 5..n
2) you create radiobutton, which is checked if sb.value ==
<currentForm>.name, where <currentForm> is the actionform defined for
the action, that is used in your HTML FORM.
3) you write sb.name

What you probably want to do is:

<logic:iterate id="sb" name="abcForm" property="daList"
indexId="index" offset='5'>
  <html:radio name="yourActionForm"
property="yourCurrentRadiobuttonValue" idName="sb" value="name" />
  <bean:write name="sb" property="name" />
</logic:iterate>

name="yourActionForm" is optional if yourCurrentRadiobuttonValue is
defined in currentForm.

See this article, it explains it very well:
http://javaboutique.internet.com/tutorials/strutsform/index-3.html

Michael J.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org