• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts question

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Framework forum where Struts questions go.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic