Couln't you use the ignore=true flag instead?

<bean:define id="bubba" name="foo" property="bar"/>
<bean:write name="bubba" ignore="true"/>

If bubba were null, nothing would get written.

You could take this one step further if you were simply checking the bean
itself and not a property of the bean for null:

<bean:write name="bubba" ignore="true"/>

would ignore if the "bubba" bean could not be found in any scope.  If you
using a property of bubba that could be null...

<bean:write name="bubba" property="bubbaProp" ignore="true"/> 

would write nothing if bubba was null but wouldn't if bubba.getBubbaProp()
returned null, then you'd have to use the bean:define version above.

Tim

-----Original Message-----
From: Bartley, Chris P [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 10, 2002 1:56 PM
To: 'Struts Users Mailing List'
Subject: RE: bean:write returning null


Have you tried doing a <bean:define> first, and then checking for null with
<logic:present>?

For example, say that you were doing this:

   <bean:write name="foo" property="bar"/>

But you want to make sure that it isn't null first...so, try this:

   <bean:define id="bubba" name="foo" property="bar"/>
   <logic:present name="bubba">
      <bean:write name="bubba"/>
   </logic:present>

(i haven't tested this, so my apologies for any syntax errors)

Hope that helps.

chris

> -----Original Message-----
> From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 3:37 PM
> To: 'Struts Users Mailing List'
> Subject: RE: bean:write returning null
> 
> 
> I tried logic:isEmpty without success.
> 
> -----Original Message-----
> From: Thinh Doan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 4:44 PM
> To: Struts Users Mailing List
> Subject: RE: bean:write returning null
> 
> 
> Can you use logic:present ?
> 
> Thinh
> 
> -----Original Message-----
> From: Galbreath, Mark [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 3:30 PM
> To: Struts (E-mail)
> Subject: bean:write returning null
> 
> 
> How are you guys testing for this in JSP?
>  
> Mark
> "De recta non tolerandum sunt."
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to