struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lionel Roux" <lionel.r...@OpenSourceConsulting.info>
Subject Re: Using JSP struts tag logic:iterate
Date Thu, 27 Mar 2003 21:51:27 GMT
I think it work because it require that objects on which you can apply this
are collections. they alll share the same model !! :p

Am I wrong ?
__________________________________________
Lionel Roux
mail: lionel.roux@OpenSourceConsulting.info
cell: +33 6 60 51 49 83
__________________________________________
This messages is certified virus free by NAV 2003
----- Original Message -----
From: "Jean-Michel Auguste" <augustejm@yahoo.fr>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Sent: Thursday, March 27, 2003 3:49 PM
Subject: Re: Using JSP struts tag logic:iterate


> Ok, now I understand.
> Thanks a lot.
>
> ----- Original Message -----
> From: "Nicolas De Loof" <nicolas.deloof@cgey.com>
> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> Sent: Thursday, March 27, 2003 15:43
> Subject: Re: Using JSP struts tag logic:iterate
>
>
> > Simply they're is no Cast at all !
> > Tags use commons-beanUtils. This package uses javaBean standard to get
> properties from objects. In fact they use the
> > java.beans.PropertyDescriptor class to get property getter and setter,
> without having to know the class used.
> >
> > Nico.
> >
> >
> >
> > > 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" <nicolas.deloof@cgey.com>
> > > To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> > > 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" <nicolas.deloof@cgey.com>
> > > > > To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> > > > > 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:
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
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
>



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


Mime
View raw message