Subject: Re: Another way to find mapped properties
From: "Anand Jayaraman" <[EMAIL PROTECTED]>
 ===
Craig/Jihn.

Do you have a example of the ActionForm and JSP using mapped property.

Thanks,

Anand


"Jing Zhou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
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?

Thanks,

Jing




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

Reply via email to