You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sriram Nookala <sr...@mediaone.net> on 2002/02/25 17:31:31 UTC

help with logic:iterate

I have the following snippet of code in my jsp:

<logic:iterate id="columnName" name="ParticipantImportWizardForm"
 property="columnNameList">

<table border="1" width="80%">
    <tr>
        <td width="50%"><h3 align="center">Column Name</h3>
        </td>
        <td width="50%"><h3 align="center">Type</h3>
        </td>
    </tr>
    <tr>
        <td width="50%"><html:text property="columnName" /></td>
        <td width="50%">
            <p>&nbsp;</p>
        </td>
    </tr>
....

I get the error "No getter method for property columnName of bean org.apache.struts.taglib.html.BEAN".

columnNameList is a collection of Strings. I can't figure out what I have to set the name and property attributes of html:text in this case.

Re: MORE help with logic:iterate

Posted by Arron Bates <ar...@pacific.net.au>.
In the nightly build, the nested tags will make easy work of this for 
you, simply swapping the tag header name a little to the following...
<nested:iterate property="myStudentListProperty">
<nested:write property="name" />
</nested:iterate>

(no, you don't have to mess around with the id's and all that. Quite easy)

To get it working on your 1.02 build.... gor here and get the 1.0 jar...
http://www.keyboardmonkey.com/struts

And it will be waiting for you in the next release of Struts when you 
upgrade (or you can just keep using the separate jar :)
The above link also has a tutorial if you get a little stuck about any 
of it.

Arron.

Saeid Zoonematkermani wrote:

> Hello all;
>
> I am sorry to bring this up again but I have looked at the docs and 
> the archives and I think I am following the instruction found in these 
> but I still can't get the iterate tag to work correctly. So I wanted 
> to post this question and see if I understand the methodology and 
> hopefully figure out what is wrong. I using struts-1.0.2.
>
> Let's say that I want to display a list of students. From the link 
> (Display Students) on page 1, I go to DisplayStudentsAction which goes 
> to the database and gets the list of students. I have a StudentBean 
> with 2 properties; name and id. The action gets the result set from 
> the database, populates one bean at a time and adds them to a vector. 
> At the end, I have a vector of StudentBeans. I put the vector in a 
> session attribute called student_list and forward to page 2.
>
> On page 2, I try to use the iterate tag to display a table of students 
> and I have tried all variations of id, name, and property I can think 
> of and some kind of error always shows up. Snippet of the JSP:
>
> <table>
> <tr>
> <td>NAME</td>
> <td>ID</td>
> </tr>
> <logic:iterate id="student" name="student_list" scope="session">
> <tr>
> <td>
> <bean:write name="student" property="name" filter="true"/>
> </td>
> <td>
> <bean:write name="student" property="id" filter="true"/>
> </td>
> </tr>
> </logic:iterate>
> </table>
>
>
> Some of the things I have done which were unsuccessful:
> - Added
> <jsp:useBean id="student" scope="page" type="packageName.StudentBean"/>
> or
> <jsp:useBean id="student" scope="session" 
> type="packageName.StudentBean"/>
> to the top of the JSP and still no use...
>
> The error I am getting most of the time is:
> javax.servlet.ServletException: bean student not found within scope
>
> Any help would be appreciated. I have read in the emails that nested 
> tags might be the way to go but I need to stay with an officially 
> released version of struts.
>
> Thanks in advance,
>
> - Saeid
>
>
>
>
>
> -- 
> 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>


MORE help with logic:iterate

Posted by Saeid Zoonematkermani <Sa...@gte.net>.
Hello all;

I am sorry to bring this up again but I have looked at the docs and the 
archives and I think I am following the instruction found in these but I 
still can't get the iterate tag to work correctly. So I wanted to post this 
question and see if I understand the methodology and hopefully figure out 
what is wrong. I using struts-1.0.2.

Let's say that I want to display a list of students. From the link (Display 
Students) on page 1, I go to DisplayStudentsAction which goes to the 
database and gets the list of students. I have a StudentBean with 2 
properties; name and id. The action gets the result set from the database, 
populates one bean at a time and adds them to a vector. At the end, I have 
a vector of StudentBeans. I put the vector in a session attribute called 
student_list and forward to page 2.

On page 2, I try to use the iterate tag to display a table of students and 
I have tried all variations of id, name, and property I can think of and 
some kind of error always shows up. Snippet of the JSP:

<table>
   <tr>
     <td>NAME</td>
     <td>ID</td>
   </tr>
   <logic:iterate id="student" name="student_list" scope="session">
   <tr>
     <td>
       <bean:write name="student" property="name" filter="true"/>
     </td>
     <td>
       <bean:write name="student" property="id" filter="true"/>
     </td>
   </tr>
   </logic:iterate>
</table>


Some of the things I have done which were unsuccessful:
- Added
<jsp:useBean id="student" scope="page" type="packageName.StudentBean"/>
or
<jsp:useBean id="student" scope="session" type="packageName.StudentBean"/>
to the top of the JSP and still no use...

The error I am getting most of the time is:
javax.servlet.ServletException: bean student not found within scope

Any help would be appreciated. I have read in the emails that nested tags 
might be the way to go but I need to stay with an officially released 
version of struts.

Thanks in advance,

- Saeid





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


Re: help with logic:iterate

Posted by Arron Bates <ar...@pacific.net.au>.
If you model it the other way (ie: a collections of objects that 
individual properties for each column. eg: ResultSet style) it will be 
much easier. Then you can point the iterate tag's property at the 
collection, and then use the nested text tags to show each of the 
properties within each bean.

Makes like _much_ easier to manage.

Arron.

Sriram Nookala wrote:

>The following worked for me:
>
><nested:iterate property="columnNameList">
> <tr>
>        <td>
>          <nested:text property="this/" />
>        </td>
>....
>
>However if I have another String collection called columnTypeList which has
>the same length as the columnNameList and which also I'd like to populate
>and display with text boxes, how would I implement that. I'd put my question
>as how would I loop thru another collection along with the collection
>mentioned in the nested:iterate tag?
>----- Original Message -----
>From: "Arron Bates" <ar...@pacific.net.au>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Monday, February 25, 2002 5:59 PM
>Subject: Re: help with logic:iterate
>
>
>>You're basically using the markup of the nested tags. If you have the
>>nightly build change your iterate tag to...
>>
>><nested:iterate property="columnNameList">
>>
>>...and your text tag to....
>><nested:text property="columnName" />
>>
>>...and of course don't forget to close the iterate tag with the
>>
></nested:iterate>
>
>>
>>If you're not on the nightly build, you can get the download from here...
>>http://www.keyboardmonkey.com/struts
>>
>>It simply makes quick work of iterating and nesting beans as you are here.
>>
>>
>>Arron.
>>
>>
>>Sriram Nookala wrote:
>>
>>>I have the following snippet of code in my jsp:
>>>
>>><logic:iterate id="columnName" name="ParticipantImportWizardForm"
>>>property="columnNameList">
>>>
>>><table border="1" width="80%">
>>>   <tr>
>>>       <td width="50%"><h3 align="center">Column Name</h3>
>>>       </td>
>>>       <td width="50%"><h3 align="center">Type</h3>
>>>       </td>
>>>   </tr>
>>>   <tr>
>>>       <td width="50%"><html:text property="columnName" /></td>
>>>       <td width="50%">
>>>           <p>&nbsp;</p>
>>>       </td>
>>>   </tr>
>>>....
>>>
>>>I get the error "No getter method for property columnName of bean
>>>
>org.apache.struts.taglib.html.BEAN".
>
>>>columnNameList is a collection of Strings. I can't figure out what I have
>>>
>to set the name and property attributes of html:text in this case.
>
>>
>>
>>--
>>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: help with logic:iterate

Posted by Sriram Nookala <sr...@mediaone.net>.
The following worked for me:

<nested:iterate property="columnNameList">
 <tr>
        <td>
          <nested:text property="this/" />
        </td>
....

However if I have another String collection called columnTypeList which has
the same length as the columnNameList and which also I'd like to populate
and display with text boxes, how would I implement that. I'd put my question
as how would I loop thru another collection along with the collection
mentioned in the nested:iterate tag?
----- Original Message -----
From: "Arron Bates" <ar...@pacific.net.au>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 25, 2002 5:59 PM
Subject: Re: help with logic:iterate


> You're basically using the markup of the nested tags. If you have the
> nightly build change your iterate tag to...
>
> <nested:iterate property="columnNameList">
>
> ...and your text tag to....
> <nested:text property="columnName" />
>
> ...and of course don't forget to close the iterate tag with the
</nested:iterate>
>
>
> If you're not on the nightly build, you can get the download from here...
> http://www.keyboardmonkey.com/struts
>
> It simply makes quick work of iterating and nesting beans as you are here.
>
>
> Arron.
>
>
> Sriram Nookala wrote:
>
> >I have the following snippet of code in my jsp:
> >
> ><logic:iterate id="columnName" name="ParticipantImportWizardForm"
> > property="columnNameList">
> >
> ><table border="1" width="80%">
> >    <tr>
> >        <td width="50%"><h3 align="center">Column Name</h3>
> >        </td>
> >        <td width="50%"><h3 align="center">Type</h3>
> >        </td>
> >    </tr>
> >    <tr>
> >        <td width="50%"><html:text property="columnName" /></td>
> >        <td width="50%">
> >            <p>&nbsp;</p>
> >        </td>
> >    </tr>
> >....
> >
> >I get the error "No getter method for property columnName of bean
org.apache.struts.taglib.html.BEAN".
> >
> >columnNameList is a collection of Strings. I can't figure out what I have
to set the name and property attributes of html:text in this case.
> >
>
>
>
> --
> 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: help with logic:iterate

Posted by Arron Bates <ar...@pacific.net.au>.
You're basically using the markup of the nested tags. If you have the 
nightly build change your iterate tag to...

<nested:iterate property="columnNameList">

...and your text tag to....
<nested:text property="columnName" />

...and of course don't forget to close the iterate tag with the </nested:iterate>


If you're not on the nightly build, you can get the download from here...
http://www.keyboardmonkey.com/struts

It simply makes quick work of iterating and nesting beans as you are here.


Arron.


Sriram Nookala wrote:

>I have the following snippet of code in my jsp:
>
><logic:iterate id="columnName" name="ParticipantImportWizardForm"
> property="columnNameList">
>
><table border="1" width="80%">
>    <tr>
>        <td width="50%"><h3 align="center">Column Name</h3>
>        </td>
>        <td width="50%"><h3 align="center">Type</h3>
>        </td>
>    </tr>
>    <tr>
>        <td width="50%"><html:text property="columnName" /></td>
>        <td width="50%">
>            <p>&nbsp;</p>
>        </td>
>    </tr>
>....
>
>I get the error "No getter method for property columnName of bean org.apache.struts.taglib.html.BEAN".
>
>columnNameList is a collection of Strings. I can't figure out what I have to set the name and property attributes of html:text in this case.
>



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


Re: help with logic:iterate

Posted by Sriram Nookala <sr...@mediaone.net>.
<html:text name="columnName" />
doesn't work since "property" is a required attribute.
----- Original Message -----
From: "keithBacon" <ke...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>; "Sriram
Nookala" <sr...@proteusmobile.com>
Sent: Monday, February 25, 2002 12:19 PM
Subject: Re: help with logic:iterate


> Hi Sri,
> try
> <html:text name="columnName" />
> instead of
> property="columnName"
>
> struts will then call the toString() method of your columnName objects.
>
> Often your columnName object would have a method like getName()
> and you would specify
> <html:text name="columnName" property="name" />
> I hope that's right!
> Keith.
>
>
>
> --- Sriram Nookala <sr...@mediaone.net> wrote:
> > I have the following snippet of code in my jsp:
> >
> > <logic:iterate id="columnName" name="ParticipantImportWizardForm"
> >  property="columnNameList">
> >
> > <table border="1" width="80%">
> >     <tr>
> >         <td width="50%"><h3 align="center">Column Name</h3>
> >         </td>
> >         <td width="50%"><h3 align="center">Type</h3>
> >         </td>
> >     </tr>
> >     <tr>
> >         <td width="50%"><html:text property="columnName" /></td>
> >         <td width="50%">
> >             <p>&nbsp;</p>
> >         </td>
> >     </tr>
> > ....
> >
> > I get the error "No getter method for property columnName of bean
> > org.apache.struts.taglib.html.BEAN".
> >
> > columnNameList is a collection of Strings. I can't figure out what I
have to
> > set the name and property attributes of html:text in this case.
> >
>
>
> =====
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Search the archive:-
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Keith Bacon - Looking for struts work - South-East UK.
> phone UK 07960 011275
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
>




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


Re: help with logic:iterate

Posted by keithBacon <ke...@yahoo.com>.
Hi Sri, 
try 
<html:text name="columnName" />
instead of
property="columnName"

struts will then call the toString() method of your columnName objects.

Often your columnName object would have a method like getName()
and you would specify 
<html:text name="columnName" property="name" />
I hope that's right!
Keith.



--- Sriram Nookala <sr...@mediaone.net> wrote:
> I have the following snippet of code in my jsp:
> 
> <logic:iterate id="columnName" name="ParticipantImportWizardForm"
>  property="columnNameList">
> 
> <table border="1" width="80%">
>     <tr>
>         <td width="50%"><h3 align="center">Column Name</h3>
>         </td>
>         <td width="50%"><h3 align="center">Type</h3>
>         </td>
>     </tr>
>     <tr>
>         <td width="50%"><html:text property="columnName" /></td>
>         <td width="50%">
>             <p>&nbsp;</p>
>         </td>
>     </tr>
> ....
> 
> I get the error "No getter method for property columnName of bean
> org.apache.struts.taglib.html.BEAN".
> 
> columnNameList is a collection of Strings. I can't figure out what I have to
> set the name and property attributes of html:text in this case.
> 


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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