On Thu, 01 Nov 2012 10:06:34 -0200, membersound <memberso...@web.de> wrote:

Sorry, I think I didn't get it.

Nope, you didn't. :P

  setupRender() {
    model.add("result", pcSource.create("Product.class", "price"));

Does this even compile? I guess it should be model.add("result", pcSource.create(Product.class), "price"));. Anyway, you're not following what I suggested at all. Have you even read it? :P In addition, you can't add more than one property with the same name.

You should implement your own PropertyConduit, not using one provided by PropertyConduitSource. Something like this (not tested).

class MultiplyPropertyConduit implements PropertyConduit {

        // that's where the logic goes
        public Object get(Object instance) {
                Product product = (Product) instance;
                return product.getPrice() * product.getQuantity();
        }

        public void set(Object instance, Object value) {}

        public Class getPropertyType() {
                return BigDecimal.class;
        }

        public T getAnnotation(Class<T> annotationClass) {
                return null:
        }

}

...

beanModel.add("multiply", new MultiplyPropertyConduitSource());

I do NOT want to introduce a getMultiply() method within my product entity (which would solve the problem as I could just add a "multiply" conduit). I
want it to be computed either in the productService or directly in the
product backing page class.

Why not? That would be perfectly good, even recommended, object-oriented modelling and programming.

--
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to