You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Joe @ Team345" <jg...@team345.com> on 2003/06/12 03:44:48 UTC
Can you send a "null" value to a form in Struts (1.1)?
Hi,
Sorry if this is an oft asked question, but I just joined the list as I
was unable to find the answer elsewhere.
I'm using StrutsRC 1.1 (with webdoclet/xdoclet going to jboss). My
question is basically in the subject: If I have a java Integer class on
a form, can I send a null value to this from a jsp? While I cannot find
a way to do so, the logic in the "requiredif" part of the Validator
makes me think that it should be possible. [In case anyone doesn't know
why I want to do this: I have several fields (html:text elements) on a
form that are optional - a common occurrence! I'm trying to send a null
for the Integer ones so that I know nothing was entered there. However,
whenever it runs I get a zero (0) instead. This happens to be a legal
value so I seem to be out of luck.
If this is not possible should all parameters passed (from a jsp) be
Strings? At least this way one can test for empty strings and take some
action accordingly.
Looking forward to any thoughts or comments from others who have
experienced this previously.
Joe Gamache
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Can you send a "null" value to a form in Struts (1.1)?
Posted by Sandeep Takhar <sa...@yahoo.com>.
Other than strings and booleans, you cannot set the
type you want.
Maybe you can always set an equivalent 'null' string
that you can check for in the validator.
Unfortunately I haven't used the validator yet.
sandeep
--- "Joe @ Team345" <jg...@team345.com> wrote:
> Hi,
>
> Sorry if this is an oft asked question, but I just
> joined the list as I
> was unable to find the answer elsewhere.
>
> I'm using StrutsRC 1.1 (with webdoclet/xdoclet going
> to jboss). My
> question is basically in the subject: If I have a
> java Integer class on
> a form, can I send a null value to this from a jsp?
> While I cannot find
> a way to do so, the logic in the "requiredif" part
> of the Validator
> makes me think that it should be possible. [In case
> anyone doesn't know
> why I want to do this: I have several fields
> (html:text elements) on a
> form that are optional - a common occurrence! I'm
> trying to send a null
> for the Integer ones so that I know nothing was
> entered there. However,
> whenever it runs I get a zero (0) instead. This
> happens to be a legal
> value so I seem to be out of luck.
>
> If this is not possible should all parameters passed
> (from a jsp) be
> Strings? At least this way one can test for empty
> strings and take some
> action accordingly.
>
> Looking forward to any thoughts or comments from
> others who have
> experienced this previously.
>
> Joe Gamache
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org