File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts question

 
Jay Richards
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to i display my bean using the tags included in struts if my bean is like this:
<code>
public class person{
PersonInfoBase personinfo;
ContactInfoBase contactinfo;
....
}
public class PersonInfoBase{
getLastName();
getBirthdate();
....
}
public class ContactInfoBase{
getAddress();
getZip();
....
}
</code>
How do i display like address or lastname is i put the class person in the session.attribute:
<code>
Person person = new Person();
request.setAttribute("person",person)
</code>
Can someshow show me how wil the jsp looks like.
thanks a lot in advance.
-jay
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Framework forum where Struts questions go.
 
Jason Menard
Sheriff
Posts: 6450
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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>
<nested:nest property="personinfo">
<nested:write property="lastName"/"
</nested:nest>
</nested:root>
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>.
HTH
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic