• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

form bean should have properties for values entered from Form but it is working without having that

 
Ranch Hand
Posts: 2599
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read that form bean is for getting the values that it gets from the Form that user enters.But in my program it is not having properties for values entered by user from Form. Still it is working fine. Please clear my confusion because the below code should not work as per what is written everywhere about form beans but it is working.




form bean




action class







thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I fixed your code tags for you.
I'm not sure what you mean by "Still it is working fine." What is working?
Is it because you can find the request parameter searchKeyword? Struts is built on the standard HTML form processing functionality. It does not replace that functionality, so you can still get request parameters via the Servlet API. Struts makes it easier by packaging all the relevant request parameters in an object. It is even easier with Struts 2, which disposes of Form Beans and uses POJO's.
 
Monica Shiralkar
Ranch Hand
Posts: 2599
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please confirm whether the below understanding is correct:

Struts 1:
Data entered from Form should have properties (and getter setter) in Form Bean.
Data to be displayed in result JSP should have properties (and getter setter) in Action Class.


Struts 2:

Both the Data entered from Form as well as Data to be displayed in result JSP should have properties (and getter setter) in Action Class should have properties in Action class.

thanks
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My answers in blue, below.

Monica. Shiralkar wrote:

Struts 1:
Data entered from Form should have properties (and getter setter) in Form Bean.
Correct
Data to be displayed in result JSP should have properties (and getter setter) in Action Class.
No. Data to be displayed should be put into the form or, alternatively, put into the request or session objects. Struts 1 does not call back to the action.


Struts 2:
Both the Data entered from Form as well as Data to be displayed in result JSP should have properties (and getter setter) in Action Class should have properties in Action class.
While technically correct, the best practice is to encapsulate the data entered or displayed in a POJO and use the Action to manage the POJO (the actual work of which should be performed in a business logic object). The Struts 2 tag library can also access the request and session objects if necessary.

 
I'm full of tinier men! And a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic