I browsed the Appendix A for EL and got the following
thoughts:
Suppose STRUTS taglib is running in a JSTL environment
with EL engine enabled. We could have a construct like
<c:forEach var="i" items="some_address_index_collection">
<bean:write name="customer" property="address[${i}]"/>
</c:forEach>
I hope the EL will set the property attribute with string
literal address[0], address[1], ... at runtime.
Craig, is the above construct legal in the future? It looks
to me pretty neat when considering arbitrary string literal
could be set by the EL engine (it also solves my problem)
Jing
----- Original Message -----
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: "Struts Developers List" <[EMAIL PROTECTED]>
Sent: Wednesday, April 24, 2002 2:38 PM
Subject: Re: Another way to find mapped properties
>
>
> On Wed, 24 Apr 2002, Jing Zhou wrote:
>
> [snip]
> > > [Craig said]
> > > If we are going to adopt the JSTL (and JSP 1.3) expression language
> > > syntax, I believe we should adopt all of it, not just a subset. For
> > > example, consider the <bean:write> tag, where you use the "name" and
> > > "property" (plus optional "scope") attributes to identify the property
to
> > > be written. The "property" attribute takes one of our proprietary
> > > expressions, so you can say something like:
> > >
> > > <bean:write name="customer" property="address.city"
scope="session"/>
> > >
> > > The equivalent using a standard JSTL tag would look like this:
> > >
> > > <c:out value="${sessionScope.customer.address.city}"/>
> > >
> >
> > Can we have syntax like this in Struts?
> > <bean:write name="customer" property="address[${key}]"
scope="session"/>
>
> This is not curently legal. Struts only accepts integer literals as
> subscripts, although you can fake it with a runtime expression:
>
> <bean:write name="customer"
> property='<%= "address[" + key + "]" %>' scope="session"/>
>
> > or in JSTL
> > <c:out value="${sessionScope.customer.address[${key}]}" />
>
> In this case, it would actually be:
>
> <c:out value="${sessionScope.customer.address[key]}"/>
>
> You don't really need to wonder what the JSTL expression language syntax
> is -- you can download the JSTL spec and read Appendix A.
>
> http://jcp.org/aboutJava/communityprocess/first/jsr052/
>
> > Where the evaluated value of ${key} at runtime could be obtained from
> > a loop tag or a tool provided model. An example value of ${key} could be
> > 0, 1, 2 ... as a looped index, or "home", "ship_to", "charge_to", etc.
> >
> > I feel the true problems I am struggling for are better expressed in the
> > above
> > examples. A more agressive syntax may looks like:
> > <html:text name="customer" property="${whatever property to post}" />
> > or something like:
> > <html:text name="customer" property="${foo1}normal_string${foo2}"/>
> >
> > I am not sure JSTL could understand the "nested expressions" or not and
> > how to express them in JSTL. The idea is somehow we could dynamically
> > assemble the string literal for the "property" attributes.
> >
>
> There are two variations of the JSTL library -- one that accepts runtime
> expressions (like the Struts case above) and one that does not.
>
> [snip]
>
> Craig
>
>
> --
> 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]>