• 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

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

 
Ranch Hand
Posts: 2925
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: 2925
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.

 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic