Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

POJO & ActionForm

 
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a scenario, where Struts & Hibernate are used,does use of ActionForm instance as POJO is a bad approach.Both resemble java bean convention's but is it good way to do so.
Morever in cases where both ActionForm as client object & POJO as persistence object are used, copying properties from ActionForm(Request Parameters) to POJO(Database mappings) is done by this way.

Can't it be done using BeanUtils class of org.apache.commons like

The source bean could be a POJO and destiation an ActionForm instance.
Can anyone explain.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In a scenario, where Struts & Hibernate are used,does use of ActionForm instance as POJO is a bad approach.Both resemble java bean convention's but is it good way to do so.



Depends upon the size of the application and the environment. In a commercial setting, it is typically considered bad form because it creates a dependency upon the Struts API in the Model. This is not good. It is better to create a plain old object in the Presentation tier (web app) and pass this off to the Model code.

You can copy the data in an ActionForm to a plain Java object with BeanUtils.
 
No, tomorrow we rule the world! With this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic