You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Izak Wessels <po...@gmail.com> on 2006/02/14 16:55:23 UTC

Render Time of Custom Component (.jwc) within a loop

Hello all,

Having a bit of a problem with my custom component inside a loop.

In my .html

<table class="mytable">
   <tr jwcid="quotationProducts" class="odd">
           .... Other fields declared ....

            <span jwcid="@If" condition="ognl:
agentSession.category.categoryName.equals('Cement')">
                    <span jwcid="cementSupplierProductSpecification">
                    </span>
            </span>
   </tr>
</table>


In my .page

    <component id="cementSupplierProductSpecification"
type="CementSupplierProductSpecification"/>

<property name="currentQuotationProduct"/>
    <component id="quotationProducts" type="For">
        <binding name="source" value="quotationProducts"/>
        <binding name="value" value="currentQuotationProduct"/>
        <binding name="element" value="literal:div"/>
        <binding name="class" value="beans.evenOdd.next"/>
    </component>


In my .java

    @InjectComponent("cementSupplierProductSpecification")
    public abstract CementSupplierProductSpecificationComponent
getCementSupplierProductSpecificationComponent();

    public SortedSet<QuotationProduct_IF> getQuotationProducts() {
        SortedSet<QuotationProduct_IF> quotationProductSet = new
TreeSet<QuotationProduct_IF>();
        quotationProductSet =
lookupQuotation().lookupQuotationProducts(getAgentSession().getCategory(),getQuotationID());

        for (Iterator i = quotationProductSet.iterator(); i.hasNext();) {
            QuotationProduct_IF quotationProduct = (QuotationProduct_IF)
i.next();

getCementSupplierProductSpecificationComponent().setSupplierProductID(
quotationProduct.getSupplierProduct().getId());
            log.info("loop id is " + quotationProduct.getSupplierProduct
().getId());
        }
        return quotationProductSet;
    }

In my CementSupplierProductSpecificationComponent

public void setSupplierProductID(Integer supplierProductID) {
        log.info("id is : " + supplierProductID);
        this.supplierProductID = supplierProductID;
    }

private CementSupplierProductSpecification_IF
lookupCementSupplierProductSpecification() {
        log.info
("*****************************************************************************");
        log.info("supplier Product id passed in from previous page is : " +
getSupplierProductID());
        log.info
("*****************************************************************************");
        CementSupplierProductSpecification_IF
cementSupplierProductSpecification = new
CementSupplierProductSpecification();
        cementSupplierProductSpecification =
cementSupplierProductSpecification.lookupCementSupplierProductSpecificationById
(getSupplierProductID());
        return cementSupplierProductSpecification;
    }

public String getCementSupplierProductShrinkage() {
        return
lookupCementSupplierProductSpecification().getCementSupplierProductSpecificationShrinkage();
}


The output is as follows :

17:28:55,681 INFO  [BuyerQuotationDetailsPage] loop id is : 34
17:28:55,681 INFO  [CementSupplierProductSpecificationComponent] id is : 34
17:28:55,681 INFO  [BuyerQuotationDetailsPage] loop id is : 35
17:28:55,681 INFO  [CementSupplierProductSpecificationComponent] id is : 35
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent] supplier
Product id passed in from previous page is : 35
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************

How the output should be is like this :

17:28:55,681 INFO  [BuyerQuotationDetailsPage] loop id is : 34
17:28:55,681 INFO  [CementSupplierProductSpecificationComponent] id is : 34
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent] supplier
Product id passed in from previous page is : 34
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************
17:28:55,681 INFO  [BuyerQuotationDetailsPage] loop id is : 35
17:28:55,681 INFO  [CementSupplierProductSpecificationComponent] id is : 35
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent] supplier
Product id passed in from previous page is : 35
17:28:55,683 INFO  [CementSupplierProductSpecificationComponent]
*****************************************************************************


If there are 2 or more Id's that have to be displayed then it only uses the
LAST id that I
passed into the Spec.

So, my question is, when does the custom component actually render inside a
loop? Only at the end
of the loop? or during each iteration of the loop?

Hope it's clear what I am trying to accomplish...

-- Izak