You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John C Cartwright <Jo...@noaa.gov> on 2003/02/13 21:26:27 UTC
JSTL and DynaActionForm
Hello All,
I'm trying to understand why I cannot access the properties in a
DynaActionForm bean via JSTL (e.g. <c:out>). For example, given a
DynaForm configured thusly:
<form-bean
name="mapserviceSummaryForm"
dynamic="true"
type="org.apache.struts.action.DynaActionForm">
<form-property name="mapserviceList" type="java.util.ArrayList"/>
</form-bean>
I am trying to access the name property of one of the beans in the
ArrayList from JSP. This works fine:
<bean:write name="mapserviceSummaryForm"
property="mapserviceList[0].name" />
but this does not:
<c:out value="${mapserviceSummaryForm.mapserviceList[0].name}" />
I don't think that it's a scope problem or the bean not being populated
because this:
<c:out value="${mapserviceSummaryForm}" />
produces this (there's only one bean in the ArrayList):
DynaActionForm[dynaClass=mapserviceSummaryForm,mapserviceList={basicworld3}]
Thanks for any help or clarification on what I'm doing wrong!
-- john
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
how to calculate A*B in jsp, where A and B are from nested:write
Posted by Denis Wang <dw...@brandmuscle.com>.
A newbie question:
Currently I have
<nested:write property='width'/>
<nested:write property='depth'/>
I want to calculate the area IN JSP (not to modify ActionForm) as width X
depth.
I suppose I am going to use scriptlet. How to achieve this?
Thanks.
Denis
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: JSTL and DynaActionForm
Posted by Brandon Goodin <ma...@phase.ws>.
since the DynaActionForm is a Map you need to access the property name with
a key. In order to access a key value in a map with JSTL you need to use the
bracket/quote combo. I have never done this... but try the syntax i have
below.
<c:out value="${mapserviceSummaryForm['mapserviceList'][0].name}" />
Also, here are some jstl references:
http://www.manning.com/bayern/appendixA.pdf
http://rs1.vtu.lt:8080/jstl-examples/index.html
Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws
-----Original Message-----
From: John C Cartwright [mailto:John.C.Cartwright@noaa.gov]
Sent: Thursday, February 13, 2003 1:26 PM
To: struts-user@jakarta.apache.org
Subject: JSTL and DynaActionForm
Hello All,
I'm trying to understand why I cannot access the properties in a
DynaActionForm bean via JSTL (e.g. <c:out>). For example, given a
DynaForm configured thusly:
<form-bean
name="mapserviceSummaryForm"
dynamic="true"
type="org.apache.struts.action.DynaActionForm">
<form-property name="mapserviceList" type="java.util.ArrayList"/>
</form-bean>
I am trying to access the name property of one of the beans in the
ArrayList from JSP. This works fine:
<bean:write name="mapserviceSummaryForm"
property="mapserviceList[0].name" />
but this does not:
<c:out value="${mapserviceSummaryForm.mapserviceList[0].name}" />
I don't think that it's a scope problem or the bean not being populated
because this:
<c:out value="${mapserviceSummaryForm}" />
produces this (there's only one bean in the ArrayList):
DynaActionForm[dynaClass=mapserviceSummaryForm,mapserviceList={basicworld3}]
Thanks for any help or clarification on what I'm doing wrong!
-- john
---------------------------------------------------------------------
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