tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Lobanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (TAP5-740) Writeable property expressions accessing java.util.Map entries at final term (T4-style)
Date Sun, 07 Jun 2009 16:28:07 GMT
Writeable property expressions accessing java.util.Map entries at final term (T4-style)

                 Key: TAP5-740
                 URL: https://issues.apache.org/jira/browse/TAP5-740
             Project: Tapestry 5
          Issue Type: Wish
          Components: tapestry-core
    Affects Versions:
            Reporter: Igor Lobanov

Consider following situation. Say there is a page which displays list of products in some
category. User must be able to add several products to shopping cart from this page with single
operation. To accomplish this we place a textfield near each product to allow user to input
desired quantity, and we place "Add to cart" submit button after the list.

As "value" parameter of TextField is bidirectional, we need some writeable location to read
initial zero from and to store entered quantity when form is submited. Thus we need to write
boilerplate stub:
public class ProductOrder {
  public Product product;
  public int quantity;

To be able to render and then process such a form, we need to create an instance of ProductOrder
for each Product in category and bind TextField values to corresponding ProductOrder.quantity.

In T4 days it could be accomplished a bit easier. We only needed to create page property of
type java.util.Map (initialized to empty map) and use binding expression like "ognl:orderMap[product]".
Then on page render all textfields' values would be set to "0", because binding expression
yields null. On page rewinding OGNL created entries in orderMap for us automatically and fills
entered values in.

While such approach definitely lacks OOP-ness, it suired well in situations when there is
no particular need in the "stub" class other than facilitate form operations. It would be
great to be able to use it in T5 with property expressions.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message