the problem is that row is a generic object until you cast it i think. I have used this in then past by using syntax like <html:radio ... value="<%=(String)((java.util.HashMap)row).get("VALUE")%>" >  Looks ugly but it works.

Note:  I have not used it with a HashMap, but have with custom objects like ((com.app.Customer) cust).getName() so i am guessing you would have to cast the get to a string as it will return a generic object as well.

Inactive hide details for Paul Moody <[EMAIL PROTECTED]>Paul Moody <[EMAIL PROTECTED]>


          Paul Moody <[EMAIL PROTECTED]>

          07/19/2005 07:53 AM

          Please respond to
          "Struts Users Mailing List" <user@struts.apache.org>

To

'Struts Users Mailing List' <user@struts.apache.org>

cc


Subject

re: Problem in Struts Tags

I did a quick test and it seems that having the
<html:radio ... value="<%=row.get("VALUE")%>" > fails
for me too. The output html contains <html:radio ...>
instead of <input type="radio" ...>.

Doing the following worked:

<% String val = (String) row.get("VALUE"); %>
<html:radio .... value="<%=val%> />

Anyway, in general I don't like seeing scriptlets in
jsps. I think your first method looked better to me
with a Collection of beans containing properties. I
think you can then use the following: <html:radio
property="xxx" idName="row" value="value" /> which
will look in the bean exposed by the iterate tag and
use its value property.

Good luck.

Paul Moody

--- raghavendra <[EMAIL PROTECTED]> wrote:

> Hi paulsmoody
>
> This just a sample program I know UI labels are not
> good, Hard coded in
> Action class.
> Main problem is value="<%=row.get("VALUE")%>" line
> not complied in JSP
> page why?
> <logic:iterate id="row" name="data"
> type="java.util.HashMap">
>   <html:radio property="expectedVia"
> value="<%=row.get("VALUE")%>"/>  
> </logic:iterate>
> -----Original Message-----
> From: Paul Moody [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 19, 2005 3:38 PM
> To: Struts Users Mailing List
> Subject: RE: Problem in Struts Tags
>
> I would expect you to have a problem with the jsp.
> You
> have an ArrayList with each element being a Map.
> When
> you iterate over the ArrayList with the
> logic:iterate
> tag each element, identified by "row", is a Map.
> This
> means that the "<bean:write name="row"
> property="label"/>" will fail because there is no
> getLabel method for the Map.
>
> You could try a <%=row.get("LABEL)%> to get the
> stored
> label from the Map which should work.
>
> However, I am not sure this is the best solution as
> you are coding your UI labels in your Action which
> is
> not best practice as far as I know.
>
> Hope this was of help.
>
> Paul Moody
>
> --- raghavendra <[EMAIL PROTECTED]>
> wrote:
>
> >
> > Please first under stand the problem, the problem
> in
> > jsp page. Why the
> > jsp page does't complile. Try the following code
> in
> > u r system.
> >
> > <logic:iterate id="row" name="data"
> > type="java.util.HashMap">
> >   <html:radio property="expectedValue"
> > value="<%=row.get("VALUE")%>"/>
> >   <bean:write name="row" property="label"/>
> > </logic:iterate>
> >  
> > OR
> > <logic:iterate id="row" name="data"
> > type="java.util.HashMap">
> > <% String value=(String)row.get("VALUE"); %>
> >   <html:radio property="expectedValue"
> > value="<%=row.get(value)%>"/>
> >   <bean:write name="row" property="label"/>
> > </logic:iterate>
> > OR
> >  
> > <logic:iterate id="row" name="data"
> scope="request">
> >
> >   <input type="radio" name="expectedVia"
> > value="<bean:write name="row"
> > property="VALUE"/>"/>
> >   <bean:write name="row" property="LABLE"/>
> > </logic:iterate>
> >
> >
> > -----Original Message-----
> > From: Marsh-Bourdon, Christopher
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 19, 2005 3:21 PM
> > To: 'Struts Users Mailing List';
> > [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: Problem in Struts Tags
> >
> > You are adding the HashMap as an item to the
> > ArrayList, not replacing
> > the
> > contents of the ArrayList with the contents of the
> > HashMap.  Try this:
> >
> > List shippers = new ArrayList(map);
> >
> > Instead of:
> >
> > shippers.add(map);
> >
> > And get rid of:
> >
> > ArrayList shippers = new ArrayList();
> >
> > Cheers
> >
> > Christopher Marsh-Bourdon
> > www.marsh-bourdon.com
> >
> > -----Original Message-----
> > From: raghavendra
> > [mailto:[EMAIL PROTECTED]]
> > Sent: 19 July 2005 10:55
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED];
> > user@struts.apache.org
> > Subject: Problem in Struts Tags
> >
> >  
> > Hi All
> >  See the following code
> >  
> >   In action class I had written like
> >  
> >   ArrayList shippers = new ArrayList();
> >   shippers.add(new LabelValueBean("UPS", "UPS"));
> >   shippers.add(new LabelValueBean("Federal
> Express",
> > "FEDX"));
> >   shippers.add(new LabelValueBean("AirBorne",
> > "AIRB"));
> >   request.setAttribute ("SHIPPERS",shippers);
> >  
> >  
> > And Jsp page written like
> >  
> > <logic:iterate id="row" name="SHIPPERS"
> >
>
type="org.apache.commons.scaffold.util.LabelValueBean">
> >   <html:radio property="expectedValue"
> > value="<%=row.getValue()%>"/>
> >   <bean:write name="row" property="label"/>
> > </logic:iterate>
> >  
> > the above code working fine  if u select any value
> > and click submit and
> > returns the  same page back  the selected  radio
> > button value is there .
> > So long as one of the values matches the
> > "expectedVia" property on our
> > ActionForm, the radio tag will still automatically
> > select the
> > appropriate
> > button.
> > But I try to use Hash Map in the following way
> but,
> > WHY IT'S NOT WORK.
> > Values matches the "expectedVia" property on our
> > ActionForm, the radio
> > tag will not select    
> > The appropriate value .tell me the reason.
> >  
> > In Action class
> >  
> >  
> >             ArrayList shippers = new ArrayList();
> >                for(int i=0; i<=1; i++){
> >                HashMap map=new HashMap();
> >                map.put("VALUE", "UPS"+i);
> >                map.put("LABLE", "UPS"+i);
> >                map.put("VALUE", "AIRB0"+i);
> >                shippers.add(map);
> >                }      
> >             request.setAttribute
> ("data",shippers);
> >  
> > in jsp I tried in  the following ways to display
> > .the selected the value
> > is
> > not there the same page send returns back.
> >  
> > <logic:iterate id="row" name="data"
> > type="java.util.HashMap">
> >   <html:radio property="expectedValue"
> > value="<%=row.get("VALUE")%>"/>
> >   <bean:write name="row" property="label"/>
> > </logic:iterate>
> >  
> > OR
> > <logic:iterate id="row" name="data"
> > type="java.util.HashMap">
> > <% String value=(String)row.get("VALUE"); %>
> >   <html:radio property="expectedValue"
> > value="<%=row.get(value)%>"/>
> >   <bean:write name="row" property="label"/>
> > </logic:iterate>
> > OR
> >  
>
=== message truncated ===






___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail
http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to