You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ScottC <sc...@verizon.net> on 2003/07/22 06:09:50 UTC

Radio active? :-)

I'm having trouble figuring out the nested:radio tag and getting the values
set. I have bean that nests a list of three other beans (a Schedule bean
that holds three date beans). Each date has three guys (each with a radio
button next to them), so I have an array that is 3x3. How do I get the
"value" out of the bean to put in the value part of the radio tag? For
example (where [] is the radio button):

7/21/2003 []Jack []Bob   []Phil
7/22/2003 []Jim   []Larry []Harry
7/23/2003 []Paul  []Ken  []John

The nested:radio tag syntax <nested:radio property="guyName" value="?" />
and I don't understand how to pull the guys name out of the bean and get it
in the value parameter. When the form is submitted, I then have to know
which guy was selected. A working code snippet of something you've done like
this would be great.

Thanks!
Scott




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


Re: Radio active? :-) or a working example of nested radio buttons

Posted by ScottC <sc...@verizon.net>.
Adam,

In my case I do not want a correctly nested name (like rows[0].crews[0]...)
if that's what you're referring to, for the text that goes in the name field
and that's what the nested:radio was giving me. Using the idName produces
the correct behavior of making all the name="" all the same and thus
allowing me to have a matrix (usually 6x4) of crew members and by clicking
on one member and getting the "value" returned in the targetMemberId field,
I can continue processing. Now, a strange behavior came up in the parsing of
the value field. I used to have a "," separating my fields so I could break
them apart (i.e. "20030727093000,14236"). Now, when the form is processed
(after I hit submit) only a portion (the 14236) of the value field is
populated back to my property in my form. I don't know how to report this as
a bug because I don't know who (ActionServlet?) is responsible for handling
the request and pulling those values. Below is a snippet of source from the
browser html. As a workaround, I've removed the comma delimiter and I can
parse after the dateTime that precedes the memberId, but boy was I surprised
when I didn't get the whole value field back in my form.


      <td>
         <input type="radio" name="targetMemberId"
value="2003072709300014236">
         Wes Lincoln
      </td>
      <td>
         <input type="radio" name="targetMemberId"
value="200307271100005163">
         John Mims
      </td>

Would I report the parsing problem (or is it normal for special processing
to occur with the value field?) to bugzilla?
Thanks,
Scott


"Adam Hardy" <ah...@cyberspaceroad.com> wrote in message
news:3F20F64F.8060907@cyberspaceroad.com...
> And that html:radio is able to reference the current iteration of the
> nested:iterate loop, and give the radio html the correctly nested name?
> If so it's seems to be encroaching on the nested taglibs behaviour.
>
> It's good.
>
> Adam
>
> ScottC wrote:
> > Adam,
> > The final code came down to this:
> >
> > <nested:iterate property="rows" >
> >  <tr align="left">
> >
> >    <td>
> >       <nested:write property="rowTitle" />
> >    </td>
> >
> >    <nested:iterate id="crewMember" property="crews">
> >       <td>
> >          <html:radio  idName="crewMember" property="lookup"
value="lookup"
> > />
> >          <nested:write property="memberName" />
> >       </td>
> >
> >    </nested:iterate>
> >
> >  </tr>
> > </nested:iterate>
> >
> > The real key to making it work lies in the idName parameter which
> > nested:radio does not support. The above will make more sense if I
describe
> > my beans. I have a schedule bean that has an ArrayList of rows. The rows
are
> > a class called ScheduleRow. Each ScheduleRow has a title (which is the
> > current date in my case) and an array of crewMembers. My challenge with
the
> > radio button was this, the lookup property is a string inside my
MemberBean
> > (the MemberBean holds the crewmember name and other information) that is
a
> > key field for my database lookup. What is displayed in the jsp is only a
> > crewmember name next to a radio button.  I just couldn't believe it
would
> > take so much effort to get the normal "value" field populated in the tag
> > (using the bean define, etc.) and I hate to admit it, but I RTFM for
> > html:radio and near the top of the doc there is a reference to how
idName
> > when populated totally changes the tags behavior.
> >
> > In summary, if you are tying to create a matrix of radio buttons and are
> > pulling your hair out, try the above approach and see if it works for
you.
> > Here's what the jsp outputs from above:
> >
> > 07/24/2003 *Furner, Bob  *Doe, John      *Smith, James
> > 07/31/2003 *Jones, Bill     *Carey, Harry  *Barber, Joe
> >
> > Collections are cool and nested tags make the jsp very simple, but it's
> > taken me some time to get it working right. Hope this helps anyone else
out
> > there. And to Adam, thanks for taking the time to respond to my plea for
> > help.
> >
> > Scott
> >
> >
> > "Adam Hardy" <ah...@cyberspaceroad.com> wrote in message
> > news:3F1DB231.2020002@cyberspaceroad.com...
> >
> >>you need someething like this
> >>
> >><nested:iterate property="ops" id="opIterate" indexId="iterateId">
> >>
> >><bean:define name="opIterate" id="currentOp"
> >>               type="foo.bar.operation.OperationValueBean"
scope="page"/>
> >>
> >><nested:radio property="guyName" value="<%=myBean.guyName(); %>" />
> >>
> >>where the bean define allows the radio button to access the current bean
> >>of the iterate loop, and then you can call the name function.
> >>
> >>hth
> >>Adam
> >>
> >>ScottC wrote:
> >>
> >>>I'm having trouble figuring out the nested:radio tag and getting the
> >
> > values
> >
> >>>set. I have bean that nests a list of three other beans (a Schedule
bean
> >>>that holds three date beans). Each date has three guys (each with a
> >
> > radio
> >
> >>>button next to them), so I have an array that is 3x3. How do I get the
> >>>"value" out of the bean to put in the value part of the radio tag? For
> >>>example (where [] is the radio button):
> >>>
> >>>7/21/2003 []Jack []Bob   []Phil
> >>>7/22/2003 []Jim   []Larry []Harry
> >>>7/23/2003 []Paul  []Ken  []John
> >>>
> >>>The nested:radio tag syntax <nested:radio property="guyName" value="?"
> >
> > />
> >
> >>>and I don't understand how to pull the guys name out of the bean and
get
> >
> > it
> >
> >>>in the value parameter. When the form is submitted, I then have to know
> >>>which guy was selected. A working code snippet of something you've done
> >
> > like
> >
> >>>this would be great.
> >>>
> >>>Thanks!
> >>>Scott
> >>>
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>
> >>>
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >




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


RE: newbie question: how to get context path?

Posted by Daniel Joshua <da...@gridnode.com>.
Oooops... thanks!

Regards,
Daniel


-----Original Message-----
From: Mike Whittaker [mailto:mike_whittaker@ntlworld.com]
Sent: Friday, 25 July, 2003 5:54 PM
To: Struts Users Mailing List; daniel.joshua@gridnode.com
Subject: RE: newbie question: how to get context path?


>-----Original Message-----
>From: Daniel Joshua [mailto:daniel.joshua@gridnode.com]
>Sent: 25 July 2003 10:48
>To: 'Struts Users Mailing List'
>Subject: newbie question: how to get context path?
>
>
>Sorry for the newbie question... my brain not responding...
>
>Using mapping.findForward(xxx).getPath(), I am able to to get the the
>context-relative path.
>
>But how do I get the full path, eg. http://localhost:8080/myApp/xxx.do ?
>

HttpServletRequest.getRequestURL()

--
Mike W


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

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


RE: newbie question: how to get context path?

Posted by Mike Whittaker <mi...@ntlworld.com>.
>-----Original Message-----
>From: Daniel Joshua [mailto:daniel.joshua@gridnode.com]
>Sent: 25 July 2003 10:48
>To: 'Struts Users Mailing List'
>Subject: newbie question: how to get context path?
>
>
>Sorry for the newbie question... my brain not responding...
>
>Using mapping.findForward(xxx).getPath(), I am able to to get the the
>context-relative path.
>
>But how do I get the full path, eg. http://localhost:8080/myApp/xxx.do ?
>

HttpServletRequest.getRequestURL()

--
Mike W


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


newbie question: how to get context path?

Posted by Daniel Joshua <da...@gridnode.com>.
Sorry for the newbie question... my brain not responding...

Using mapping.findForward(xxx).getPath(), I am able to to get the the
context-relative path.

But how do I get the full path, eg. http://localhost:8080/myApp/xxx.do ?


Regards,
Daniel


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


Re: Radio active? :-) or a working example of nested radio buttons

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
And that html:radio is able to reference the current iteration of the 
nested:iterate loop, and give the radio html the correctly nested name? 
If so it's seems to be encroaching on the nested taglibs behaviour.

It's good.

Adam

ScottC wrote:
> Adam,
> The final code came down to this:
> 
> <nested:iterate property="rows" >
>  <tr align="left">
> 
>    <td>
>       <nested:write property="rowTitle" />
>    </td>
> 
>    <nested:iterate id="crewMember" property="crews">
>       <td>
>          <html:radio  idName="crewMember" property="lookup" value="lookup"
> />
>          <nested:write property="memberName" />
>       </td>
> 
>    </nested:iterate>
> 
>  </tr>
> </nested:iterate>
> 
> The real key to making it work lies in the idName parameter which
> nested:radio does not support. The above will make more sense if I describe
> my beans. I have a schedule bean that has an ArrayList of rows. The rows are
> a class called ScheduleRow. Each ScheduleRow has a title (which is the
> current date in my case) and an array of crewMembers. My challenge with the
> radio button was this, the lookup property is a string inside my MemberBean
> (the MemberBean holds the crewmember name and other information) that is a
> key field for my database lookup. What is displayed in the jsp is only a
> crewmember name next to a radio button.  I just couldn't believe it would
> take so much effort to get the normal "value" field populated in the tag
> (using the bean define, etc.) and I hate to admit it, but I RTFM for
> html:radio and near the top of the doc there is a reference to how idName
> when populated totally changes the tags behavior.
> 
> In summary, if you are tying to create a matrix of radio buttons and are
> pulling your hair out, try the above approach and see if it works for you.
> Here's what the jsp outputs from above:
> 
> 07/24/2003 *Furner, Bob  *Doe, John      *Smith, James
> 07/31/2003 *Jones, Bill     *Carey, Harry  *Barber, Joe
> 
> Collections are cool and nested tags make the jsp very simple, but it's
> taken me some time to get it working right. Hope this helps anyone else out
> there. And to Adam, thanks for taking the time to respond to my plea for
> help.
> 
> Scott
> 
> 
> "Adam Hardy" <ah...@cyberspaceroad.com> wrote in message
> news:3F1DB231.2020002@cyberspaceroad.com...
> 
>>you need someething like this
>>
>><nested:iterate property="ops" id="opIterate" indexId="iterateId">
>>
>><bean:define name="opIterate" id="currentOp"
>>               type="foo.bar.operation.OperationValueBean" scope="page"/>
>>
>><nested:radio property="guyName" value="<%=myBean.guyName(); %>" />
>>
>>where the bean define allows the radio button to access the current bean
>>of the iterate loop, and then you can call the name function.
>>
>>hth
>>Adam
>>
>>ScottC wrote:
>>
>>>I'm having trouble figuring out the nested:radio tag and getting the
> 
> values
> 
>>>set. I have bean that nests a list of three other beans (a Schedule bean
>>>that holds three date beans). Each date has three guys (each with a
> 
> radio
> 
>>>button next to them), so I have an array that is 3x3. How do I get the
>>>"value" out of the bean to put in the value part of the radio tag? For
>>>example (where [] is the radio button):
>>>
>>>7/21/2003 []Jack []Bob   []Phil
>>>7/22/2003 []Jim   []Larry []Harry
>>>7/23/2003 []Paul  []Ken  []John
>>>
>>>The nested:radio tag syntax <nested:radio property="guyName" value="?"
> 
> />
> 
>>>and I don't understand how to pull the guys name out of the bean and get
> 
> it
> 
>>>in the value parameter. When the form is submitted, I then have to know
>>>which guy was selected. A working code snippet of something you've done
> 
> like
> 
>>>this would be great.
>>>
>>>Thanks!
>>>Scott
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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


Re: Radio active? :-) or a working example of nested radio buttons

Posted by ScottC <sc...@verizon.net>.
Adam,
The final code came down to this:

<nested:iterate property="rows" >
 <tr align="left">

   <td>
      <nested:write property="rowTitle" />
   </td>

   <nested:iterate id="crewMember" property="crews">
      <td>
         <html:radio  idName="crewMember" property="lookup" value="lookup"
/>
         <nested:write property="memberName" />
      </td>

   </nested:iterate>

 </tr>
</nested:iterate>

The real key to making it work lies in the idName parameter which
nested:radio does not support. The above will make more sense if I describe
my beans. I have a schedule bean that has an ArrayList of rows. The rows are
a class called ScheduleRow. Each ScheduleRow has a title (which is the
current date in my case) and an array of crewMembers. My challenge with the
radio button was this, the lookup property is a string inside my MemberBean
(the MemberBean holds the crewmember name and other information) that is a
key field for my database lookup. What is displayed in the jsp is only a
crewmember name next to a radio button.  I just couldn't believe it would
take so much effort to get the normal "value" field populated in the tag
(using the bean define, etc.) and I hate to admit it, but I RTFM for
html:radio and near the top of the doc there is a reference to how idName
when populated totally changes the tags behavior.

In summary, if you are tying to create a matrix of radio buttons and are
pulling your hair out, try the above approach and see if it works for you.
Here's what the jsp outputs from above:

07/24/2003 *Furner, Bob  *Doe, John      *Smith, James
07/31/2003 *Jones, Bill     *Carey, Harry  *Barber, Joe

Collections are cool and nested tags make the jsp very simple, but it's
taken me some time to get it working right. Hope this helps anyone else out
there. And to Adam, thanks for taking the time to respond to my plea for
help.

Scott


"Adam Hardy" <ah...@cyberspaceroad.com> wrote in message
news:3F1DB231.2020002@cyberspaceroad.com...
> you need someething like this
>
> <nested:iterate property="ops" id="opIterate" indexId="iterateId">
>
> <bean:define name="opIterate" id="currentOp"
>                type="foo.bar.operation.OperationValueBean" scope="page"/>
>
> <nested:radio property="guyName" value="<%=myBean.guyName(); %>" />
>
> where the bean define allows the radio button to access the current bean
> of the iterate loop, and then you can call the name function.
>
> hth
> Adam
>
> ScottC wrote:
> > I'm having trouble figuring out the nested:radio tag and getting the
values
> > set. I have bean that nests a list of three other beans (a Schedule bean
> > that holds three date beans). Each date has three guys (each with a
radio
> > button next to them), so I have an array that is 3x3. How do I get the
> > "value" out of the bean to put in the value part of the radio tag? For
> > example (where [] is the radio button):
> >
> > 7/21/2003 []Jack []Bob   []Phil
> > 7/22/2003 []Jim   []Larry []Harry
> > 7/23/2003 []Paul  []Ken  []John
> >
> > The nested:radio tag syntax <nested:radio property="guyName" value="?"
/>
> > and I don't understand how to pull the guys name out of the bean and get
it
> > in the value parameter. When the form is submitted, I then have to know
> > which guy was selected. A working code snippet of something you've done
like
> > this would be great.
> >
> > Thanks!
> > Scott
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >




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


Re: Radio active? :-)

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
you need someething like this

<nested:iterate property="ops" id="opIterate" indexId="iterateId">

<bean:define name="opIterate" id="currentOp"
               type="foo.bar.operation.OperationValueBean" scope="page"/>

<nested:radio property="guyName" value="<%=myBean.guyName(); %>" />

where the bean define allows the radio button to access the current bean 
of the iterate loop, and then you can call the name function.

hth
Adam

ScottC wrote:
> I'm having trouble figuring out the nested:radio tag and getting the values
> set. I have bean that nests a list of three other beans (a Schedule bean
> that holds three date beans). Each date has three guys (each with a radio
> button next to them), so I have an array that is 3x3. How do I get the
> "value" out of the bean to put in the value part of the radio tag? For
> example (where [] is the radio button):
> 
> 7/21/2003 []Jack []Bob   []Phil
> 7/22/2003 []Jim   []Larry []Harry
> 7/23/2003 []Paul  []Ken  []John
> 
> The nested:radio tag syntax <nested:radio property="guyName" value="?" />
> and I don't understand how to pull the guys name out of the bean and get it
> in the value parameter. When the form is submitted, I then have to know
> which guy was selected. A working code snippet of something you've done like
> this would be great.
> 
> Thanks!
> Scott
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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