Hi Nicolas,
After some reading, I wrote the following code that works pretty well...

 <logic:iterate name="objA" property="hTable" id="objB" >
      Next element is <bean:write name="objB" property="value.prop" />
[<bean:write name="objB" property="key" />]
 </logic:iterate>

I don't fully understand how the cast from Object to ObjB is performed but
it works....
Thanks for your help.


----- Original Message -----
From: "Nicolas De Loof" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, March 27, 2003 12:24
Subject: Re: Using JSP struts tag logic:iterate


> YOu can read this on struts-logic doc :
>
> Normally, each object exposed by the iterate tag is an element of the
underlying collection you are iterating over.
> However, if you iterate over a Map, the exposed object is of type
Map.Entry that has two properties:
>
> key - The key under which this item is stored in the underlying Map.
> value - The value that corresponds to this key.
>
> So, you should use :
>
> logic:iterate name="objA" property="hTable" id="objB" indexId="ind"
type="ObjB" >
>      Next element is <bean:write name="objB" property="value.prop" />
>  [<bean:write name="value.ind"/>]
> </logic:iterate>
>
> Nico.
>
> > Thanks for your help Nico,
> > As you recommend I've checked into my ObjB class and the property "prop"
> > looks well formed :
> >
> > - "prop" is of type String
> > - there is only one getter (getProp() ) and one setter (setProp(String
p) )
> > - getProp() is public
> >
> > As I mentionned in my first append, I used two ways to code the
> > logic:iterate tag.
> > I can understand the first error message as there is no mention anywhere
of
> > the type of  "objB" (as "objB" is stored as an Object type in the
> > Hashtable). But I don't understand the second error message ("invalid
Cast")
> > as I specify the type for "objB".
> >
> >
> > ----- Original Message -----
> > From: "Nicolas De Loof" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Thursday, March 27, 2003 11:27
> > Subject: Re: Using JSP struts tag logic:iterate
> >
> >
> > > You don't need <jsp:useBean> as struts tags look into scope themself.
> > (usebean create a scriptlet variable from a bean)
> > >
> > > Your code looks fine. Look at objB code, getter should not be well
formed.
> > > - be carreful about uppercase beginig properties
> > > - be carreful not to have mulitple setters with different data types
> > (IFAIK it will break javaBean PropertyInfo)
> > > - be carreful getter is public
> > >
> > > Nico.
> > >
> > >
> > >
> > > Hi,
> > > I'm a bit confusing using the jsp struts tag logic:iterate.
> > > Here is my problem.
> > >
> > > In my business logic I've created an object (let's call it "objA")
that
> > contains a Hashtable which itself contain a list
> > > of objects ("objB") . The Hastable object ("hTable") can be accessed
> > through getter and setter from "objA".
> > > I want now to display as a table the property "prop" of all "objB"
objects
> > contained in the Hashtable "hTable" ("prop"
> > > is a String  and can be accessed through getter and setter from
"objB".
> > >
> > > Before launching the jsp I've put objA in the HTTP request.
> > >
> > > Then I've coded the following  in the Jsp :
> > >
> > > <jsp:useBean id="objA" class="ObjA" scope="request"></jsp:useBean>
> > >
> > > <logic:iterate name="objA" property="hTable" id="objB" indexId="ind" >
> > >     Next element is <bean:write name="objB" property="prop" />
> > [<bean:write name="ind"/>]
> > > </logic:iterate>
> > >
> > > Coding this, I get the following error :
> > >
> > > [Servlet Error]-[No getter method for property prop of bean objB]:
> > >
> > >
> > > I tried then to code :
> > >
> > > <jsp:useBean id="objA" class="ObjA" scope="request"></jsp:useBean>
> > >
> > > <logic:iterate name="objA" property="hTable" id="objB" indexId="ind"
> > type="ObjB" >
> > >     Next element is <bean:write name="objB" property="prop" />
> > [<bean:write name="ind"/>]
> > > </logic:iterate>
> > >
> > > In this case I get the following error :
> > >
> > > [Servlet Error]-[JSP 1.2 Processor]: java.lang.ClassCastException:
> > java.util.Hashtable$Entry
> > >
> > > Can anyone tell me what I am doing wrong please ?
> > >
> > > Thanks for your help
> > >
> > > Jean-Michel Auguste
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to