You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Harrison <sr...@yahoo.co.uk> on 2004/02/29 01:27:16 UTC

contrib:Table - Help

Hi ,
  I am trying to use contrib:Table instead of simple Foreach because for some special feature of contrib:Table.
I am following more or less same as LocaleSelect / LocalList example except that data is comming from DB. 
The problem I am facing is, I am not able to bind correct object (InvoiceInfo) to Select link for each asn every row. I believe I have to do some job in "pageBeginRender" method, but I am not sure what I have to do. Just to avoid Null pointer Exception I am hard coding some value in Listener as shown below.
 
Could one you PLEASE,PLEASE help me as I am new to Tapestry / contrib:Table.
 
 
-------- .page  BEGIN----------------------------
 
<component id="tableView" type="contrib:TableView">
        <binding name="source" expression="invoiceList"/>
        <binding name="columns">
                'Invoice NO:invoiceNO, Product:product, Qty:quantity, '+
                '!select'
        </binding>
    </component>
 
    <component id="directSelect" type="DirectLink">
        <binding name="listener" expression="listeners.selectInvoice"/>
        <binding name="parameters" expression="selectInvoiceContext"/>
        <binding name="row" expression="currentInvoice"/>
    </component>
 
    <property-specification name="currentInvoice" type="com.afx.invoice.domain.pojo.InvoiceInfo"/>
.
.
---------- .page END -----------------------------
 
------------.java BEDING ------------------------
public abstract class ListInvoice extends InvoiceBasePage implements PageRenderListener {
 
 public List getInvoiceList() {
        Visit visit = (Visit) getVisit();
        int companyId = visit.getUser().getPk().getCompanyId();
        return getInvoiceFacade().getInvoices(companyId);
    }
 
//Listener
 public void selectInvoice(IRequestCycle objCycle) {
        Object[] arrParams = objCycle.getServiceParameters();
        InvoiceInfo objInfo = new InvoiceInfo(new Integer(arrParams[3].toString()).intValue(),
                new String("1"),
                arrParams[0].toString(),
                arrParams[2].toString(), 1);
    }
    public String[] getSelectFixtureContext() {
        InvoiceInfo objInfo = getCurrentInvoicee();
        return new String[]{
            "InvoiceNo",
            "Product",
            String.valueOf(10)
        };
 
public abstract VCFixtureInfo getCurrentFixture();
 
 protected void finishLoad() {
        getPage().addPageRenderListener(this);
    }
 
public void pageBeginRender(PageEvent event) {
 }
 
------------.java END -----------------------------
 
When the above code is executed the last coloumn "Select" will have always hard code value. Insted it should have correct values as in InvoiceInfo for that particular row.
 
Is my approach correct in Implementing Table component?
 
Your help is very much appreciated.
 
 
Regards
Hary.

		
---------------------------------
  Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now

Re: contrib:Table - Help

Posted by Sanjeev Hiremath <sc...@yahoo.com>.
Hello Mind Bridge,

  Thank you very much for your help and it worked
magically.
I am learning more and more about contrib:Table. what
a wonderfull component!.

Regards
Harry.


	
	
		
___________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

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


Re: contrib:Table - Help

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

You do not need to do anything in pageBeginRender for what you describe, I
believe.

What probably causes you the problems is that the following binding
    <binding name="row" expression="currentInvoice"/>
is in the directSelect component but should be in tableRows instead (or in
Table, if you use that instead of TableView). This is the parameter that
says where to store the currently rendered row, in your case the current
invoice.

I also assume that you have sth like this in your HTML:
<span jwcid="selectColumnValue@Block">
    <a jwcid="directSelect">select</a>
</span>
This will define how the 'select' column will look. Without it, the column
will render the value obtained by calling getSelect() on the invoice.

Does this help?

----- Original Message ----- 
From: "John Harrison" <sr...@yahoo.co.uk>
To: <ta...@jakarta.apache.org>
Sent: Sunday, February 29, 2004 2:27 AM
Subject: contrib:Table - Help


> Hi ,
>   I am trying to use contrib:Table instead of simple Foreach because for
some special feature of contrib:Table.
> I am following more or less same as LocaleSelect / LocalList example
except that data is comming from DB.
> The problem I am facing is, I am not able to bind correct object
(InvoiceInfo) to Select link for each asn every row. I believe I have to do
some job in "pageBeginRender" method, but I am not sure what I have to do.
Just to avoid Null pointer Exception I am hard coding some value in Listener
as shown below.
>
> Could one you PLEASE,PLEASE help me as I am new to Tapestry /
contrib:Table.
>
>
> -------- .page  BEGIN----------------------------
>
> <component id="tableView" type="contrib:TableView">
>         <binding name="source" expression="invoiceList"/>
>         <binding name="columns">
>                 'Invoice NO:invoiceNO, Product:product, Qty:quantity, '+
>                 '!select'
>         </binding>
>     </component>
>
>     <component id="directSelect" type="DirectLink">
>         <binding name="listener" expression="listeners.selectInvoice"/>
>         <binding name="parameters" expression="selectInvoiceContext"/>
>         <binding name="row" expression="currentInvoice"/>
>     </component>
>
>     <property-specification name="currentInvoice"
type="com.afx.invoice.domain.pojo.InvoiceInfo"/>
> .
> .
> ---------- .page END -----------------------------
>
> ------------.java BEDING ------------------------
> public abstract class ListInvoice extends InvoiceBasePage implements
PageRenderListener {
>
>  public List getInvoiceList() {
>         Visit visit = (Visit) getVisit();
>         int companyId = visit.getUser().getPk().getCompanyId();
>         return getInvoiceFacade().getInvoices(companyId);
>     }
>
> //Listener
>  public void selectInvoice(IRequestCycle objCycle) {
>         Object[] arrParams = objCycle.getServiceParameters();
>         InvoiceInfo objInfo = new InvoiceInfo(new
Integer(arrParams[3].toString()).intValue(),
>                 new String("1"),
>                 arrParams[0].toString(),
>                 arrParams[2].toString(), 1);
>     }
>     public String[] getSelectFixtureContext() {
>         InvoiceInfo objInfo = getCurrentInvoicee();
>         return new String[]{
>             "InvoiceNo",
>             "Product",
>             String.valueOf(10)
>         };
>
> public abstract VCFixtureInfo getCurrentFixture();
>
>  protected void finishLoad() {
>         getPage().addPageRenderListener(this);
>     }
>
> public void pageBeginRender(PageEvent event) {
>  }
>
> ------------.java END -----------------------------
>
> When the above code is executed the last coloumn "Select" will have always
hard code value. Insted it should have correct values as in InvoiceInfo for
that particular row.
>
> Is my approach correct in Implementing Table component?
>
> Your help is very much appreciated.
>
>
> Regards
> Hary.
>
>
> ---------------------------------
>   Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now


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