You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Susan Bradeen <Su...@softlanding.com> on 2003/04/01 22:32:08 UTC

Re: DynaActionForm with logic:present

It appears (I am sure I missed some docs about this somewhere ... ) that 
DynaActionForm String properties are initialized to an empty String, 
unless otherwise set in the config file. The <logic:present> will never 
work as expected, since there aren't any null String property values. 
Subclassing the DynaActionForm (or DynaValidatorForm in my case), and 
overriding the initialize() method, the String properties can be set to 
null. If these property values are not set again in the action, the values 
remain at null. This allows the <logic:present> in the JSP to work as 
expected.
 
If I have missed some glaring negative issue in doing this, please someone 
feel free to share it with me. 

Thanks,
Susan

On 04/01/2003 01:18:56 PM "Susan Bradeen" wrote:

> Can I use <logic:present> with DynaActionForm properties?
> 
> If my form property is null, I don't want the property text box, to
> display in my jsp page. This works fine with an ActionForm, but using a
> DynaActionForm I get a blank text box for the property showing up.
> 
> In the code below, the action's if-statement will not invoke, and the
> property value will not be set. Doesn't this mean that the property 
value
> should be null? And doesn't that mean that the <logic:present> in the 
jsp
> should not invoke either?
> 
> JSP contains (in part):
> 
> <logic:present name="myform" property="firstName" >
> <html:text property="firstName" />
> </logic:present>
> 
> Action contains:
> 
> DynaValidatorForm myForm = (DynaValidatorForm)form;
> if (false) { myForm.set("firstName", myBean.getFirstName); }
> 
> struts-config contains:
> 
> <form-bean name="myform" type="o.a.s.validator.DynaValidatorForm">
> <form-property name="firstName" type="java.lang.String" />
> </form-bean>
> 
> I haven't been able to find an example using this tag and this form type
> together. Can anyone please point me to an example of this? And, as 
usual,
> other suggestions and corrections to the above are greatly appreciated.
> 
> Susan Bradeen
> susanb@softlanding.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: DynaActionForm with logic:present

Posted by Ian Hunter <ih...@hunterweb.net>.
check logic:empty

----- Original Message ----- 
From: "Susan Bradeen" <Su...@softlanding.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 01, 2003 3:32 PM
Subject: Re: DynaActionForm with logic:present


> It appears (I am sure I missed some docs about this somewhere ... ) that 
> DynaActionForm String properties are initialized to an empty String, 
> unless otherwise set in the config file. The <logic:present> will never 
> work as expected, since there aren't any null String property values. 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org