You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vadim Pesochinskiy <vp...@gmail.com> on 2005/06/30 19:15:55 UTC

Anyone looked at BetterPetShop?

Hello!

Looking at better pet shop (betterpetshop.dev.java.net) application, and 
cannot understand why most of page classes are abstract. Abstract 
methods are getters and setters. There are no concrete classes that 
extend them. Does Tapestry use run-time class enhancing for page classes?

Re: Anyone looked at BetterPetShop?

Posted by Pablo Ruggia <pr...@gmail.com>.
Yes, Tapestry use class enhacement.

On 6/30/05, Vadim Pesochinskiy <vp...@gmail.com> wrote:
> 
> Hello!
> 
> Looking at better pet shop (betterpetshop.dev.java.net<http://betterpetshop.dev.java.net>) 
> application, and
> cannot understand why most of page classes are abstract. Abstract
> methods are getters and setters. There are no concrete classes that
> extend them. Does Tapestry use run-time class enhancing for page classes?
> 
>

Re: Anyone looked at BetterPetShop?

Posted by Pablo Ruggia <pr...@gmail.com>.
On 7/1/05, Vadim Pesochinskiy <vp...@gmail.com> wrote:
> 
> Yes, that helps. Thanks a lot.
> 
> Bright idea, it would be interesting to try find bugs in code that does
> not exist.


That code is generated by the framework, tested by thounthends of people. I 
don't think you'll gonna need to debug it. Also class enhacement helps a lot 
to reduce the repetitive code.




I am wondering how far run-time byte code generation will go...
> 
> Todd O'Bryan wrote:
> 
> > Because if you implement the methods, you're responsible for
> > initializing and otherwise dealing with the page properties. If you
> > leave them abstract Tapestry takes care of all of that for you. You
> > only have to even declare the abstract methods if you actually call
> > them in your own Java code, and that's just to make the compiler
> > happy. Any calls that Tapestry makes internally (to set or get
> > properties from the page) happen automatically.
> >
> > It's a little confusing and indirect, but it really does make your
> > life easier.
> >
> > HTH,
> > Todd
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

RE: Anyone looked at BetterPetShop?

Posted by Adam Saltiel <ad...@btinternet.com>.
Well, you don't find bugs in the enhanced code, the bugs (runtime
exceptions) point back to your own code. After a while of working like
this, and knowing your own app, you begin to understand where the bugs
originate by e.g. looking at the stack trace and thinking about how
things should be working by keeping in mind the architecture of the app.
There is also a clear distinction between what is set up as components
and in the module descriptor and what you add in your own code. That is
there are typical bugs associated with the former and once that is
stable it is possible to work on elaborating your code to take account
of, say, business logic or display requirements only touching your .jwc
in a very controlled way, so you would have a very good idea where the
bugs originate at this stage.

Adam

> -----Original Message-----
> From: Vadim Pesochinskiy [mailto:vpesochi@gmail.com]
> Sent: Friday, July 01, 2005 5:19 AM
> To: Tapestry users
> Subject: Re: Anyone looked at BetterPetShop?
>
> Yes, that helps. Thanks a lot.
>
> Bright idea, it would be interesting to try find bugs in code that
does
> not exist. I am wondering how far run-time byte code generation will
go...
>
> Todd O'Bryan wrote:
>
> > Because if you implement the methods, you're responsible for
> > initializing and otherwise dealing with the page properties. If you
> > leave them abstract Tapestry takes care of all of that for you. You
> > only have to even declare the abstract methods if you actually call
> > them in your own Java code, and that's just to make the compiler
> > happy. Any calls that Tapestry makes internally (to set or get
> > properties from the page) happen automatically.
> >
> > It's a little confusing and indirect, but it really does make your
> > life easier.
> >
> > HTH,
> > Todd
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Anyone looked at BetterPetShop?

Posted by Vadim Pesochinskiy <vp...@gmail.com>.
Yes, that helps. Thanks a lot.

Bright idea, it would be interesting to try find bugs in code that does 
not exist. I am wondering how far run-time byte code generation will go...

Todd O'Bryan wrote:

> Because if you implement the methods, you're responsible for  
> initializing and otherwise dealing with the page properties. If you  
> leave them abstract Tapestry takes care of all of that for you. You  
> only have to even declare the abstract methods if you actually call  
> them in your own Java code, and that's just to make the compiler  
> happy. Any calls that Tapestry makes internally (to set or get  
> properties from the page) happen automatically.
>
> It's a little confusing and indirect, but it really does make your  
> life easier.
>
> HTH,
> Todd
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Anyone looked at BetterPetShop?

Posted by Todd O'Bryan <to...@mac.com>.
Because if you implement the methods, you're responsible for  
initializing and otherwise dealing with the page properties. If you  
leave them abstract Tapestry takes care of all of that for you. You  
only have to even declare the abstract methods if you actually call  
them in your own Java code, and that's just to make the compiler  
happy. Any calls that Tapestry makes internally (to set or get  
properties from the page) happen automatically.

It's a little confusing and indirect, but it really does make your  
life easier.

HTH,
Todd

On Jun 30, 2005, at 9:22 PM, Vadim Pesochinskiy wrote:

> OK. Here is an example of page class that he has. Abstract methods  
> are getters and setters. Same methods are referenced in  
> corresponding .page file, also listed below. I am absolutely  
> clueless as to what would be the reason for leaving this methods  
> abstract.
>
> I would imagine tapestry will do enhancing to wrap implementations  
> of setters to know if object has to be stored in session, but why  
> would you want to leave methods and class abstract and not have  
> class that implements it?
>
> I am pondering if he uses some code generation to create java beans  
> that are domain objects used with hibernate, but I do not see any  
> evidence of that anywhere in the source tree or build files.
>
>
>
> package org.apache.tapestry.pets.presentation.pages;
>
> import johnmammen.betterpetshop.service.PetshopManager;
>
> import org.apache.tapestry.IRequestCycle;
> import org.apache.tapestry.event.PageEvent;
> import org.apache.tapestry.event.PageRenderListener;
> import org.apache.tapestry.pets.PetshopBasePage;
>
> import org.apache.tapestry.pets.domain.model.IProduct;
>
> import org.apache.tapestry.pets.presentation.components.PagedModel;
>
> public abstract class CategoryPage extends PetshopBasePage implements
>        PageRenderListener {
>
>    //for getting the petshop service
>    public abstract PetshopManager getPetshopService();
>
>    public void pageBeginRender(PageEvent event) {
>        if (getModel() == null)
>            setModel(new PagedModel());
>
>        if (getCategory() != null) {
>            //getting the petshop service
>            setProductList(getPetshopService().findByCategory 
> (getCategory()));
>        }
>
>    }
>
>    public void selectItem(IRequestCycle cycle) {
>        Object[] parameters = cycle.getServiceParameters();
>        String prodid = ((String) parameters[0]);
>        String prodname = ((String) parameters[1]);
>        ProductCategoryPage productcategory = (ProductCategoryPage)  
> cycle
>                .getPage("ProductCategory");
>        productcategory.setProdID(prodid);
>        productcategory.setProdName(prodname);
>        cycle.activate(productcategory);
>    }
>
>    public void directJumpToPage(IRequestCycle cycle) {
>        Object[] parameters = cycle.getServiceParameters();
>        int page = ((Integer) parameters[0]).intValue();
>        int pCount = ((Integer) parameters[1]).intValue();
>        setCategory((String) parameters[2]);
>
>        PagedModel nmodel = new PagedModel();
>        nmodel.setPageCount(pCount);
>        nmodel.setPageToShow(page);
>        setModel(nmodel);
>    }
>
>    public abstract void setCategory(String value);
>
>    public abstract String getCategory();
>
>    public abstract void setProductList(IProduct[] productList);
>
>    public abstract IProduct[] getProductList();
>
>    public abstract int getProductPage();
>
>    public abstract void setProductPage(int productPage);
>
>    public abstract IProduct getProduct();
>
>    public abstract void setProduct(IProduct product);
>
>    public abstract PagedModel getModel();
>
>    public abstract void setModel(PagedModel model);
>
> }
>
> <?xml version="1.0"?>
> <!DOCTYPE page-specification PUBLIC
> "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
>
> <page-specification  
> class="org.apache.tapestry.pets.presentation.pages.CategoryPage">
>
>    <property-specification name="category" type="java.lang.String"/>
>    <property-specification name="product"  
> type="org.apache.tapestry.pets.domain.model.IProduct"/>       
> <property-specification name="productList"  
> type="org.apache.tapestry.pets.domain.model.IProduct[]"/>
>    <property-specification name="productPage" type="int"/>
>    <property-specification name="model"  
> type="org.apache.tapestry.pets.presentation.components.PagedModel"/>
>    <property-specification name="petshopService"  
> type="johnmammen.betterpetshop.service.PetshopManager">
>    global.appContext.getBean("petshopService")
>    </property-specification>
>   </page-specification>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Anyone looked at BetterPetShop?

Posted by Vadim Pesochinskiy <vp...@gmail.com>.
OK. Here is an example of page class that he has. Abstract methods are 
getters and setters. Same methods are referenced in corresponding .page 
file, also listed below. I am absolutely clueless as to what would be 
the reason for leaving this methods abstract.

I would imagine tapestry will do enhancing to wrap implementations of 
setters to know if object has to be stored in session, but why would you 
want to leave methods and class abstract and not have class that 
implements it?

I am pondering if he uses some code generation to create java beans that 
are domain objects used with hibernate, but I do not see any evidence of 
that anywhere in the source tree or build files.



package org.apache.tapestry.pets.presentation.pages;

import johnmammen.betterpetshop.service.PetshopManager;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.event.PageRenderListener;
import org.apache.tapestry.pets.PetshopBasePage;

import org.apache.tapestry.pets.domain.model.IProduct;

import org.apache.tapestry.pets.presentation.components.PagedModel;

public abstract class CategoryPage extends PetshopBasePage implements
        PageRenderListener {

    //for getting the petshop service
    public abstract PetshopManager getPetshopService();

    public void pageBeginRender(PageEvent event) {
        if (getModel() == null)
            setModel(new PagedModel());

        if (getCategory() != null) {
            //getting the petshop service
            
setProductList(getPetshopService().findByCategory(getCategory()));
        }

    }

    public void selectItem(IRequestCycle cycle) {
        Object[] parameters = cycle.getServiceParameters();
        String prodid = ((String) parameters[0]);
        String prodname = ((String) parameters[1]);
        ProductCategoryPage productcategory = (ProductCategoryPage) cycle
                .getPage("ProductCategory");
        productcategory.setProdID(prodid);
        productcategory.setProdName(prodname);
        cycle.activate(productcategory);
    }

    public void directJumpToPage(IRequestCycle cycle) {
        Object[] parameters = cycle.getServiceParameters();
        int page = ((Integer) parameters[0]).intValue();
        int pCount = ((Integer) parameters[1]).intValue();
        setCategory((String) parameters[2]);

        PagedModel nmodel = new PagedModel();
        nmodel.setPageCount(pCount);
        nmodel.setPageToShow(page);
        setModel(nmodel);
    }

    public abstract void setCategory(String value);

    public abstract String getCategory();

    public abstract void setProductList(IProduct[] productList);

    public abstract IProduct[] getProductList();

    public abstract int getProductPage();

    public abstract void setProductPage(int productPage);

    public abstract IProduct getProduct();

    public abstract void setProduct(IProduct product);

    public abstract PagedModel getModel();

    public abstract void setModel(PagedModel model);

}

<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
 "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
 "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<page-specification 
class="org.apache.tapestry.pets.presentation.pages.CategoryPage">

    <property-specification name="category" type="java.lang.String"/>
    <property-specification name="product" 
type="org.apache.tapestry.pets.domain.model.IProduct"/>   
    <property-specification name="productList" 
type="org.apache.tapestry.pets.domain.model.IProduct[]"/>
    <property-specification name="productPage" type="int"/>
    <property-specification name="model" 
type="org.apache.tapestry.pets.presentation.components.PagedModel"/>
    <property-specification name="petshopService" 
type="johnmammen.betterpetshop.service.PetshopManager">
    global.appContext.getBean("petshopService")
    </property-specification>
   
</page-specification>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Anyone looked at BetterPetShop?

Posted by Adam Saltiel <ad...@btinternet.com>.
betterpetshop, no.
Page class runtime enhancement, yes.

Adam

> -----Original Message-----
> From: Vadim Pesochinskiy [mailto:vpesochi@gmail.com]
> Sent: Thursday, June 30, 2005 6:16 PM
> To: Tapestry users
> Subject: Anyone looked at BetterPetShop?
>
> Hello!
>
> Looking at better pet shop (betterpetshop.dev.java.net) application,
and
> cannot understand why most of page classes are abstract. Abstract
> methods are getters and setters. There are no concrete classes that
> extend them. Does Tapestry use run-time class enhancing for page
classes?



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org