You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jana Navaneethan <ja...@labs.gte.com> on 2002/11/13 17:55:05 UTC

Problem with using Vector?

Hi,
       I have a Vector in my form bean which contains multiple Objects, I
want to loop through the contents of this Vector in my JSP page, I have a
getListingsSummary() method in my form bean which is viewListingForm, But
for some reason when I call my JSP it throws some exception like
No bean found under attribute key viewListingBean

Here is my iterate tag
<logic:iterate id="viewListingBean" name="viewListingForm"
property="listingsSummary">

Here is my form Bean

   public Vector getListingsSummary()
   {
      return(this.listingsSummary);
   }

public void setListingsSummary(Vector listingsSummary)
   {
      this.listingsSummary = listingsSummary;
   }


My Action class sets the form bean before forwarding to the JSP page..

ViewListingForm listingform = (ViewListingForm) form;
listingform.setListingsSummary(listingsSummary);


BTW what is this id means in the iterate tag? Any help would be greatly
appreciated!

Thanks in advance,
Jana.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with using Vector?

Posted by "C. Struts" <st...@cmbsystems.com>.
id is the name of the localized object.  In the example below localName is
yourBean.yourVector which you'll use inside the iterate tags.

<logic:iterate id="localName" name="yourBean" property="yourVector">
  <bean:write name="localName" property="vectorProperty1" />
  <bean:write name="localName" property="vectorProperty2" />
  ...
</logic:iterate>

-c

----- Original Message -----
From: "Jana Navaneethan" <ja...@labs.gte.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 11:55 AM
Subject: Problem with <logic:iterate> using Vector?


> Hi,
>        I have a Vector in my form bean which contains multiple Objects, I
> want to loop through the contents of this Vector in my JSP page, I have a
> getListingsSummary() method in my form bean which is viewListingForm, But
> for some reason when I call my JSP it throws some exception like
> No bean found under attribute key viewListingBean
>
> Here is my iterate tag
> <logic:iterate id="viewListingBean" name="viewListingForm"
> property="listingsSummary">
>
> Here is my form Bean
>
>    public Vector getListingsSummary()
>    {
>       return(this.listingsSummary);
>    }
>
> public void setListingsSummary(Vector listingsSummary)
>    {
>       this.listingsSummary = listingsSummary;
>    }
>
>
> My Action class sets the form bean before forwarding to the JSP page..
>
> ViewListingForm listingform = (ViewListingForm) form;
> listingform.setListingsSummary(listingsSummary);
>
>
> BTW what is this id means in the iterate tag? Any help would be greatly
> appreciated!
>
> Thanks in advance,
> Jana.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with using Vector?

Posted by Brian Hickey <bh...@r-effects.com>.
Jana,

I think I see part of the problem. Here is some further info:

<jsp:useBean id="viewListing" scope="session" type="com.ViewListingBean"/>

-- When you use type="com.ViewListingBean"... do you have a class named
ViewListingBean that has a 'package com' directive at the top? If so - good.
If not - that needs to be corrected.

-- The "id" in the usebean tag refers to the exact name of the bean your
action class placed into request/session scope.

-- The logic:iterate should look like..
<logic:iterate id="anythingYouLike" name="viewListing"
property="listingsSummary" type="java.util.Vector">

-- Then you can use tags nested in the iterate as:
    <bean:write name="anythingYouLike" property="someProperty"/>
</logic:iterate>

You are correct - JSP/Struts will not allow redefinition of beans with the
same name in the same page/template/tile.

HTH

Brian



----- Original Message -----
From: "Jana Navaneethan" <ja...@labs.gte.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 1:20 PM
Subject: Re: Problem with <logic:iterate> using Vector?


> Hi Brian,
>                Thanks for your help I appreciate it. Actually I have a
> ViewListingBean which represents the Object in the listingsSummary Vector.
> In my JSP, I have already defined bean like this
> <jsp:useBean id="viewListing" scope="session" type="com.ViewListingBean"/>
>
> When I try to use same id "viewListing" in my iterate tag it complains
about
> the id been already defined?
> I need to use the "viewListing" bean id for displaying some other
properties
> in my JSP page. Now how do I define my id in iterate tag? which
reperesents
> the same bean.
>
> Actual error message is
> No bean found under attribute key viewListingBean
>
> Thanks,
> Jana.
>
> ----- Original Message -----
> From: "Brian Hickey" <bh...@r-effects.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, November 13, 2002 12:45 PM
> Subject: Re: Problem with <logic:iterate> using Vector?
>
>
> > Jana,
> >
> > It would help to see the actual error.
> >
> > More below...
> > > Hi,
> > >        I have a Vector in my form bean which contains multiple
Objects,
> I
> > > want to loop through the contents of this Vector in my JSP page, I
have
> a
> > > getListingsSummary() method in my form bean which is viewListingForm,
> But
> > > for some reason when I call my JSP it throws some exception like
> > > No bean found under attribute key viewListingBean
> > >
> > > Here is my iterate tag
> > > <logic:iterate id="viewListingBean" name="viewListingForm"
> > > property="listingsSummary">
> >
> > This says you have a bean named "ViewListingForm" that has some scope
> > (request/session) in your JSP. Also that you will refer to that items in
> the
> > property collection in "listingsSummary" by the scripting variable
> > "ViewListingBean". The property accesses the collection (List/Vector)
you
> > want by calling the form getter for "listingsSummary".
> >
> > To be thorough, you will need to include the "type" attribute to
identify
> > the object type that will be found in the collection "listingsSummary".
It
> > looks like type="java.util.Vector".
> >
> > >
> > > Here is my form Bean
> > >
> > >    public Vector getListingsSummary()
> > >    {
> > >       return(this.listingsSummary);
> > >    }
> > >
> > > public void setListingsSummary(Vector listingsSummary)
> > >    {
> > >       this.listingsSummary = listingsSummary;
> > >    }
> > >
> >
> > The getter will be called by the iterate tag for "listingsSummary" and
you
> > have the case correct.
> >
> > >
> > > My Action class sets the form bean before forwarding to the JSP page..
> > >
> > > ViewListingForm listingform = (ViewListingForm) form;
> > > listingform.setListingsSummary(listingsSummary);
> > >
> > >
> > > BTW what is this id means in the iterate tag? Any help would be
greatly
> > > appreciated!
> >
> > Always check the Javadoc (start at: http://jakarta.apache.org/struts/ ).
> The
> > "id" attribute names the scripting variable you will use within the
> iterate
> > tag. In other words, each object contained in the Vector
"listingsSummary"
> > will be referred to as "ViewListingBean".
> >
> > So you can now use ViewListingBean to access the individual properties
of
> > the objects in your listingsSummary. For example <bean:write
> > name="ViewListingBean" property="someProperty"/>
> >
> > >
> > > Thanks in advance,
> > > Jana.
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with using Vector?

Posted by Jana Navaneethan <ja...@labs.gte.com>.
Hi Brian,
               Thanks for your help I appreciate it. Actually I have a
ViewListingBean which represents the Object in the listingsSummary Vector.
In my JSP, I have already defined bean like this
<jsp:useBean id="viewListing" scope="session" type="com.ViewListingBean"/>

When I try to use same id "viewListing" in my iterate tag it complains about
the id been already defined?
I need to use the "viewListing" bean id for displaying some other properties
in my JSP page. Now how do I define my id in iterate tag? which reperesents
the same bean.

Actual error message is
No bean found under attribute key viewListingBean

Thanks,
Jana.

----- Original Message -----
From: "Brian Hickey" <bh...@r-effects.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, November 13, 2002 12:45 PM
Subject: Re: Problem with <logic:iterate> using Vector?


> Jana,
>
> It would help to see the actual error.
>
> More below...
> > Hi,
> >        I have a Vector in my form bean which contains multiple Objects,
I
> > want to loop through the contents of this Vector in my JSP page, I have
a
> > getListingsSummary() method in my form bean which is viewListingForm,
But
> > for some reason when I call my JSP it throws some exception like
> > No bean found under attribute key viewListingBean
> >
> > Here is my iterate tag
> > <logic:iterate id="viewListingBean" name="viewListingForm"
> > property="listingsSummary">
>
> This says you have a bean named "ViewListingForm" that has some scope
> (request/session) in your JSP. Also that you will refer to that items in
the
> property collection in "listingsSummary" by the scripting variable
> "ViewListingBean". The property accesses the collection (List/Vector) you
> want by calling the form getter for "listingsSummary".
>
> To be thorough, you will need to include the "type" attribute to identify
> the object type that will be found in the collection "listingsSummary". It
> looks like type="java.util.Vector".
>
> >
> > Here is my form Bean
> >
> >    public Vector getListingsSummary()
> >    {
> >       return(this.listingsSummary);
> >    }
> >
> > public void setListingsSummary(Vector listingsSummary)
> >    {
> >       this.listingsSummary = listingsSummary;
> >    }
> >
>
> The getter will be called by the iterate tag for "listingsSummary" and you
> have the case correct.
>
> >
> > My Action class sets the form bean before forwarding to the JSP page..
> >
> > ViewListingForm listingform = (ViewListingForm) form;
> > listingform.setListingsSummary(listingsSummary);
> >
> >
> > BTW what is this id means in the iterate tag? Any help would be greatly
> > appreciated!
>
> Always check the Javadoc (start at: http://jakarta.apache.org/struts/ ).
The
> "id" attribute names the scripting variable you will use within the
iterate
> tag. In other words, each object contained in the Vector "listingsSummary"
> will be referred to as "ViewListingBean".
>
> So you can now use ViewListingBean to access the individual properties of
> the objects in your listingsSummary. For example <bean:write
> name="ViewListingBean" property="someProperty"/>
>
> >
> > Thanks in advance,
> > Jana.
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Problem with using Vector?

Posted by Brian Hickey <bh...@r-effects.com>.
Jana,

It would help to see the actual error.

More below...
> Hi,
>        I have a Vector in my form bean which contains multiple Objects, I
> want to loop through the contents of this Vector in my JSP page, I have a
> getListingsSummary() method in my form bean which is viewListingForm, But
> for some reason when I call my JSP it throws some exception like
> No bean found under attribute key viewListingBean
>
> Here is my iterate tag
> <logic:iterate id="viewListingBean" name="viewListingForm"
> property="listingsSummary">

This says you have a bean named "ViewListingForm" that has some scope
(request/session) in your JSP. Also that you will refer to that items in the
property collection in "listingsSummary" by the scripting variable
"ViewListingBean". The property accesses the collection (List/Vector) you
want by calling the form getter for "listingsSummary".

To be thorough, you will need to include the "type" attribute to identify
the object type that will be found in the collection "listingsSummary". It
looks like type="java.util.Vector".

>
> Here is my form Bean
>
>    public Vector getListingsSummary()
>    {
>       return(this.listingsSummary);
>    }
>
> public void setListingsSummary(Vector listingsSummary)
>    {
>       this.listingsSummary = listingsSummary;
>    }
>

The getter will be called by the iterate tag for "listingsSummary" and you
have the case correct.

>
> My Action class sets the form bean before forwarding to the JSP page..
>
> ViewListingForm listingform = (ViewListingForm) form;
> listingform.setListingsSummary(listingsSummary);
>
>
> BTW what is this id means in the iterate tag? Any help would be greatly
> appreciated!

Always check the Javadoc (start at: http://jakarta.apache.org/struts/ ). The
"id" attribute names the scripting variable you will use within the iterate
tag. In other words, each object contained in the Vector "listingsSummary"
will be referred to as "ViewListingBean".

So you can now use ViewListingBean to access the individual properties of
the objects in your listingsSummary. For example <bean:write
name="ViewListingBean" property="someProperty"/>

>
> Thanks in advance,
> Jana.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>