You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steve Salkin <ss...@NetVendor.com> on 2001/06/14 18:54:36 UTC

nested logic:present tags do not short-circuit

Hi-

Am I correct to say that in the case of nested <logic:present> tags, the
false evaluation of the first one will not "short-circuit", or prevent the
evaluation of, the second one?

For example, in the case that a Form has a Bean A, which itself has a Bean
B, and when B is null, the following:
  <logic:present name="A" property="B">
    <logic:present name="A" property="B.property">
      some jsp/html
    </logic:present>
  </logic:present>

will still fail because the second logic tag is evaluated and the
null-pointer is dereferenced. 

If this is correct, is this by design? Is this a bug? Is there a way to
accomplish what I am trying to do here?

Any thoughts appreciated.

Thanks,

S-

Re: nested logic:present tags do not short-circuit

Posted by Ted Husted <hu...@apache.org>.
The first tags says if A.B is not null rather than if A && B are not
null. 

You may need to use more nesting, maybe something like 

  <logic:present name="A">
    <logic:present name="A" property="B">
	<logic:present name="A" property="B.property">
	       some jsp/html
        </logic:present>
     </logic:present>
   </logic:present>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/


> Steve Salkin wrote:
> 
> Hi-
> 
> Am I correct to say that in the case of nested <logic:present> tags,
> the false evaluation of the first one will not "short-circuit", or
> prevent the evaluation of, the second one?
> 
> For example, in the case that a Form has a Bean A, which itself has a
> Bean B, and when B is null, the following:
>   <logic:present name="A" property="B">
>     <logic:present name="A" property="B.property">
>       some jsp/html
>     </logic:present>
>   </logic:present>
> 
> will still fail because the second logic tag is evaluated and the
> null-pointer is dereferenced.
> 
> If this is correct, is this by design? Is this a bug? Is there a way
> to accomplish what I am trying to do here?
> 
> Any thoughts appreciated.
> 
> Thanks,
> 
> S-