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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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

Reply via email to