File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts question" Watch "Struts question" New topic

Struts question

Jay Richards
Ranch Hand

Joined: Jan 16, 2003
Posts: 58
how to i display my bean using the tags included in struts if my bean is like this:
public class person{
PersonInfoBase personinfo;
ContactInfoBase contactinfo;
public class PersonInfoBase{
public class ContactInfoBase{
How do i display like address or lastname is i put the class person in the session.attribute:
Person person = new Person();
Can someshow show me how wil the jsp looks like.
thanks a lot in advance.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Moving this to the Framework forum where Struts questions go.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
<bean:write name="person" property="contactinfo.address"/>
<bean:write name="person" property="personinfo.lastName"/>
Or you could use nested tags:
<nested:root name="person">
<nested:nest property="contactinfo">
<nested:write property="address"/"
<nested:nest property="personinfo">
<nested:write property="lastName"/"
If this was part of a form, you wouldn't need to use <nested:root>, since it would assume the form bean.
You'll want to be familiar with both ways of doing this as each have times when one is perferable to the other. For instance, if either one of your bean attributes was an array or collection of beans, then nested tags are usually much cleaner. But in the simple case you have here, there's no reason not to go with <bean:write>.
I agree. Here's the link:
subject: Struts question
It's not a secret anymore!