On Tue, 23 Apr 2002, Jing Zhou wrote:

> Date: Tue, 23 Apr 2002 13:29:40 -0500
> From: Jing Zhou <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: Struts Developers List <[EMAIL PROTECTED]>
> Subject: Another way to find mapped properties
>
> Struts 1.1 will introduce mapped property in the form beans.
> The PropertyUtils find it by looking for patterns:
> property_name{mapped_key}
>
> I am not aware of any in depth discussion about using
> { } as a mapped property key identifier before, but I have
> several concerns about the use of { }.
>
> * In XSLT spec as well as JSTL spec, { } is used for
>    expressions.
>
> * We can use property_name[mapped_key] to identify
>   a mapped property in the following algorithm:
>
>   When see property_name[string_literal], test the first
>   character to see it is digit or not. if not, treat the
>   string_literal as mapped key. Otherwise, parse the
>   string_literal into int, if parsing successfully, treat it
>   as int index. If exception occurs, treat it as mapped key.
>
>   I did this some time ago, because I see people can do
>   document["href"] in JavaScript, and element[non_integer_index]
>   in XML style sheet.
>
> * If we could reserve the { } for expression, we may see
>   Struts addressing pattern like this in the future:
>
>   a.b[{$i}].c[{$j}], or simply a.b[$i].c[$j]
>   where {$i}, {$j} come from JSP scoped variables or tool scoped
>   variables. It solves multi-loop problems too. Implementation is
>   relative easy, just like what you do for indexed attributes
>   prepareIndex() in BaseHandlerTag. Another function
>   prepareProperty(...) will evaluate any expressions in property attributes.
>
> Could some Struts experts share your thinking on this subject
> and advise me any pros or cons of this approach?
>

Well, the mapped property handlers actually use parentheses ("(" and ")")
instead of curly braces ("{" and "}").  Does that alleviate your concern?

My belief is that we should ultimately migrate to using the same
expression language used in JSTL (and what will be used in JSP 1.3).  For
the most part, we can accomplish that by adding new attributes to existing
Struts tags that recognize the new syntax -- and leave the existing
attributes alone.  The new attribute names would match (as much as
possible) the JSTL conventions for names.

Does that make sense?

> Thanks,
>
> Jing
>

Craig



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to