You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael McCallister <r2...@email.sps.mot.com> on 2001/02/26 19:16:44 UTC
logic:present Property Oddity?
I'm using the logic:present tag to avoid displaying a section of a
html:form if a particular bean is missing. Given the documentation, I expected
<logic:present scope="session" name="myBean" property="myProperty">
to behave something like this (in pseudocode):
if (session.getAttribute("myBean") != null &&
session.getAttribute("myBean").getMyProperty() != null)
// Display the body of the logic:present tag
but instead, it seems to behave like this:
if (session.getAttribute("myBean").getMyProperty() != null)
// Display the body of the logic:present tag
The problem this causes is that if I specify a property and my session bean
doesn't exist, I get a ServletException that complains "Cannot find bean
myBean in scope session". In order to get the behavior I expect, it looks
like I have to nest some logic:present tags like this:
<logic:present scope="session" name="myBean">
<logic:present scope="session" name="myBean" property="myProperty">
Which, of course, looks unnecessarily redundant. Is this behavior as
intended, or is this a bug? If the behavior changed to the form I
expected, would this cause any existing user code to break?
Mike
____________________________________
Mike McCallister