You know, the far simpler answer here, assuming null doesn't have any special meaning to your app, is to simply initialize your fields in your ActionForms. I.e.,
public class myForm extends ActionForm { private String firstName = ""; public void setFirstName(String inFirstName) { firstName = inFirstName; } public String getFirstName() { return firstName; } } Notice no extra code in the accessor. Whether the form is session-scoped or request-scoped, you'll be guaranteed the fields start out with empty strings. Now just assure that no code sets a null and your good to go... one way to accomplish that is to do: public void setFirstName(String inFirstName) { if (inFirstName == null) { firstName = ""; } else [ firstName = inFirstName; } } There! You should never see anything but a valid string or an empty string in your ActionForm, regardless of scope or what gets passed in. Again, this assumes that you don't want to differentiate between "" and null, which I would be willing to bet is most of the time for most people. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] On Thu, November 10, 2005 12:49 pm, Frank W. Zammetti said: > Hi Chris, > > As with most things, it depends on your app... what would be most > appropriate to get from your ActionForm? If you never want to get a null > out of it, you can do the check in the accessor of the ActionForm. If > it's something that is a valid return, you probably will want to do the > check in the Action and branch as appropriate. > > As has been said many times on the list, an ActionForm is meant to serve > as a DTO between the client and the Action (ultimately). Since your > talking HTTP, and all HTTP knows is Strings, the canonoical "best > practice" is to only have Strings in an ActionForm (subject to the > exceptions to that rule of course). This is especially important when > returning to a page and repopulating with the form. Chances are you won't > want to see "null" in input fields, so I'd say in most cases it makes more > sense to never get null from an ActionForm, only an empty string. > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > AIM: fzammetti > Yahoo: fzammetti > MSN: [EMAIL PROTECTED] > > On Thu, November 10, 2005 12:37 pm, Chris Pat said: >> Hello >> What is the best way to handle, in an Action, form >> fields that are blank? If you have a simple getter >> that just returns the field, how do you handle it when >> the field is not in the session b/c it was not filled >> in? Do I just check for fieldName==null in the getter >> of the ActionForm? tia. >> >> >> >> __________________________________ >> Yahoo! FareChase: Search multiple travel sites in one click. >> http://farechase.yahoo.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]