• 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 1 Would ActionForm be Null

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is common to see example Action class containing these:



But the point is, why check for a null form? Does that mean the Action class could receive a null ActionForm even under normal condition (assuming there is no error in the struts-config.xml and we've defined our ActionForm properly)? And what should we do if a null form is received?
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not common to see if(form != null)....

I guess, If you define everything properly in struts-config.xml then, this if-condition is not needed. For example, if you try to print the form whether it is null or not, it will print the actionForm what ever you are passing in to the execute method.

Unless you do not intialize the ActionForm bean, it will not be null.

Thanks & Regards,
Gayathri Chowduru.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is only one condition that I know of that would cause the form to be null and that is if you don't define a name attribute in your action mapping. Since multiple action mappings could point to the same action class, it is conceivable that the form could be null under some circumstances and not null under others.

This is a very unusual situation, though. If you always define a name attribute for your actions, I wouldn't bother checking for a null form every time.
 
reply
    Bookmark Topic Watch Topic
  • New Topic