• 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

Alternatives to Struts tags ???

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
usually i transder data from my Action to the JSPs with DTOs, like the following.

And i usually get this data back in my JSP with something like the following.
[code]
<logic resent name="addressVO" scope="request">
City is: <bean:write name="addressVO" property="city" scope="request"/>
Street is: <bean:write name="addressVO" property="street" scope="request"/>
</logic resent>
Are there alternatives to this or are we always stuck with struts tags?
Thanks,
ltcmelo
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<% AddressVO addressVO = (AddressVO)request.getAttribute("addressVO");
if( addressVO != null){ %>
City is: <%= addressVO.getCity() %>
Street is: <%= addressVO.getStreet() %>
<%}%>

You're never STUCK with Struts. If something can be done WITH Struts, there is some workaround WITHOUT it.
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc,
this was exactly what i wanted to know.
After all, the dto is now part of the request object... i need some more studying on jsps.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a nice trick you might like to know. If you hand the DTO or VO off to the ActionForm, you can EASILY call the getters/setters of the DTO in Struts tags.
For instance, property="person.address.zipcode" would effectively call to your ActionForm:
getPerson().getAddress().getZipcode()
and
getPerson().getAddress().setZipcode()
Where the ActionForm would have a "person" bean(our DTO/VO inside the ActionForm) that has an "address" bean that has a "zipcode" bean.
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're saying the case i handle a DTO to ActionForm or to Action (because, doesn't the ActionForm comes from a html form - from a page?).
Then you said


Where the ActionForm would have a "person" bean(our DTO/VO inside the ActionForm) that has an "address" bean that has a "zipcode" bean.


The ActionForm (or Action?) will have a person bean... OK!
And a has a Address bean... OK!
That has a ZipCode bean...??? Isn't the zipcode just o property of address bean?
Thanks,
ltcmelo
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
continuing...
I'm just trying to understand it well.
The sample code you exposed would be placed in the ActionForm or inside the Action for example???
Thanks,
ltcmelo
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry,
think i got it now.
You're telling options of how to get data from the bean in the JSP returned by Action rigth!?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um... the only "code" that you would write was the property attribute which goes in the jsps.
The VO/DTO would be in the ActionForm. My point is that Struts can convert a dotted notation in a property attribute (found in Struts tags of a jsp) into the corresponding getter/setter.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic