You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Slattery, Tim - BLS" <Sl...@bls.gov> on 2004/11/15 20:05:22 UTC

Can't find property - but it's there

I'm still struggling with this problem. The latest twist is that I've put
some debug code into the JSP page. The relevant code looks like this:

<%
gov.bls.idcf.ppi.struts.SeasAdjBean xx =
(gov.bls.idcf.ppi.struts.SeasAdjBean)request.getAttribute("SeasAdjBean");
    
if (xx == null)
{
%>
<!-- object not found!! -->
<%
}
else
{
ArrayList qq = xx.getSeasAdjs();
%>
<!-- There are <%=qq.size()%> elements!!! -->
<%
}
%>    
    <c:forEach items="${SeasAdjBean.seasAdjs}" var="seasAdjs"
varStatus="stat">

The scriptlet accesses the getSeasAdjs property, and simply dumps its size
as a comment on the page. Then the c:forEach tag tries to access the same
property. And fails. The scriptlet generates this line in the page source:

<!-- There are 12 elements!!! -->

And that's the last line generated. The wl-domain.log (Weblogic system log)
shows this:

javax.servlet.jsp.JspException: An error occurred while evaluating custom
action attribute "items" with value "${SeasAdjBean.seasAdjs}": Unable to
find a value for "seasAdjs" in object of class
"gov.bls.idcf.ppi.struts.SeasAdjBean" using operator "." (null)

Which does not seem possible given that the "12 elements" line appeared.
Using <logic:iterate ... > gets the same result. What gives?




--
Tim Slattery
Slattery_T@bls.gov


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


Re: Can't find property - but it's there

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Slattery, Tim - BLS" <Sl...@bls.gov>
> <%
> gov.bls.idcf.ppi.struts.SeasAdjBean xx =
> (gov.bls.idcf.ppi.struts.SeasAdjBean)request.getAttribute("SeasAdjBean");
> %>
>     <c:forEach items="${SeasAdjBean.seasAdjs}" var="seasAdjs"
> varStatus="stat">
> The scriptlet accesses the getSeasAdjs property, and simply dumps its size
> as a comment on the page. Then the c:forEach tag tries to access the same
> property. And fails.

I believe that's the intended behavior.  JSTL can't "see" scriptlet
variables.  In the JSTL 1.0 specification, it's section 2.2 that talks about
scoped variables:

"Because JSTL supports an expression language, the need for scripting
variables is significantly reduced. This is why all the JSTL tags expose
information only as JSP scoped attributes (no scripting variable exposed)"

Usually one sees people attempting to access something they've created with
<c:set> in a scriptlet, and you seem to be doing it the other way around,
but I think you're running into the same issue.

HTH,
-- 
Wendy Smoak


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