HELP!

H

Himalia

Hi everyone

I have a problem with struts and jsp

I have a form and an action in struts, in the action code I make a
call to a EJB and get a collection of Account value objects called
"AccountVO"

and in the same action code i set this collection in session,

Now....
how do I, using the logic:iterator tag, can I display the account
names and ids for all the accounts in my collection??

ie. how do i get the collection out of session and display their
details on the screen??

Any help is appreciated
Thanks
Himalia
 
J

Joerg Gippert

Himalia said:
Hi everyone

Hi Himalia,
[snip]
Now....
how do I, using the logic:iterator tag, can I display the account
names and ids for all the accounts in my collection??

ie. how do i get the collection out of session and display their
details on the screen??

First, you need to take care, that your colelctions is in the session scope
of your request.
You do that with
request.getSession().setAttribute("MyCollection",collection) command, where
"collection" is the collection itselfe and "MyCollection" is the name of the
collection you can reference it later in you JSP. Set the attribute in the
actionservlet which forwards*to* your JSP. Inside the JSP, you can use the
iterator tags to iterate over the collection.
<logic: iterate id="objectInsideCollection" collection="MyCollection">
<bean:write: name="objectInsideCollection" property="myobjectvalue" />
</logic:iterate>

Make sure, that the objects stored inside the collection have the
appropriate getter and setter methods. In the example above, you would have
to write getter and setter methods (well, at least a getter) for the value
"MyObjectValue". eg

class objectInsideCollection
{
private String myobjectvalue;

public String getMyobjectvalue()
{
return myobjectvalue;
}

HTH.
Regards,
Joerg
 
S

Sudsy

Himalia said:
Hi everyone

I have a problem with struts and jsp

I have a form and an action in struts, in the action code I make a
call to a EJB and get a collection of Account value objects called
"AccountVO"

and in the same action code i set this collection in session,

Now....
how do I, using the logic:iterator tag, can I display the account
names and ids for all the accounts in my collection??

ie. how do i get the collection out of session and display their
details on the screen??

Any help is appreciated
Thanks
Himalia

<logic:iterate id="account" name="name_of_session_attribute">
<bean:write name="account" property="name_of_field_in_account"/>
....
</logic:iterate>

Format appropriately.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top