You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Martin Carel <ma...@pricerunner.com> on 2006/02/02 10:58:34 UTC

contrib:Table : advices requested

Hi folks!

I'm using the contrib:Table for the first time. I'm using the source and 
columns parameters (and therefore not the tableModel parameter).

My source is a List of DOs, where each DO contains some fields (Date, 
double, int, etc.) with getters.

--

Q1: My table does show up as expected, with the page navigation system. 
But when I'm trying to change the page, I have this error:

Failure invoking listener method 'public void 
org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1

and that's an ArrayIndexOutOfBoundsException: 1.

I have a similar error when I'm trying to sort a column. It really does 
sound easy to solve, but I'm stuck.

--

Q2: I have a column which displays a price. So quite naturally the field 
in my DO is a double. I want a string in front of my double, so I 
figured I needed to have a column with a custom ColumnEvaluator. 
Something like this:

    public ITableColumn getPriceColumn() {
        SimpleTableColumn priceColumn = new SimpleTableColumn("priceId",
                "Price", new PriceColumnEvaluator(), true);
        return priceColumn;
    }

    private static class PriceColumnEvaluator implements 
ITableColumnEvaluator {    
        public Object getColumnValue(ITableColumn objColumn, Object 
objRow) {
            DO row = (DO) objRow;
            String output = row.getCurrency() + " " + row.getPrice();
            return output;
        }
    }

However, I suspect my price sorting does not work anymore because now 
the data type for my price column is a String (since my Evaluator 
returns a String).  I was not comfortable with doing this formatting 
thing (adding the currency sign) in my evaluator in the first place, 
since it was not "pure data" stuff. Would you have implemented it elsewhere?

Related to this, I will need another column in which I'll have to 
display a little picture (which will be a link) and a few other things. 
Is using a customColumnEvaluator the preferred way to do it?

Again, any hints appreciated.

/Martin


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


Re: contrib:Table : advices requested

Posted by Daniel Lydiard <dl...@hotmail.com>.
I derived my code from the examples found here:

http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.html

I didn't do the model initialization the same way he did, but it should give 
you a good idea on how to use a custom ITableColumnModel and 
IBasicTableModel.


----- Original Message ----- 
From: "Andreas Bulling" <sp...@phoenix.hadiko.de>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, March 03, 2006 3:48 AM
Subject: Re: contrib:Table : advices requested


> Hi Daniel,
>
> would you mind to provide some example code for your ITableColumnModel/
> IBasicTableModel? Thanks a lot if this is possible!
>
> Sincerly,
>  Andreas
>
>
> On 02. Feb 2006 - 10:59:16, Daniel Lydiard wrote:
> | They way I got mine to work (I think my thread was the one you were
> | referring too) was initialize the table in pageAttached() and used 
> @Persist
> | for the source/column getters.
> |
> | So something like:
> | @Persist
> | public abstract ITableColumnModel getColumns()
> | public abstract void setColumns(ITableColumnModel foo)
> |
> | @Persist
> | public abstract IBasicTableModel getTableModel()
> | public abstract void setTableModel(IBasicTableModel bar)
> |
> | Then in pageAttached (that's what I did) {
> |  setColumns(new Foo());
> |  setTableModel(new Bar());
> | }
> |
> | You could also initialize in some method like "activatePage" or whatever
> | and have a Link listener called the method to initialize the data.
> |
> | I dunno if this is the proper way of doing things (I fairly new to
> | Tapestry), but it works for me with caching/no-caching modes.
>
> ---------------------------------------------------------------------
> 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: Tacos ajax direct link

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's a tacos limitation...Tapestry was never written with this requirement
being known :) It will be fixed ~hopefully~ in 4.1, and definitely in tap5.

On 3/3/06, Daniel Lydiard <dl...@hotmail.com> wrote:
>
> When i click on an AjaxDirectLink, I'm noticing in my log file that the
> whole page is being re-rendered in the background, then the small
> component
> i told AjaxDirectLink to update will update.
>
> So everything works, it just seems inneffecient, especially when it's
> re-rendering my contrib:Table component when clicking on an Ajax link.
>
> Am i doing something wrong, or is this more of a Tapestry limitation?
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: Tacos ajax direct link

Posted by Daniel Lydiard <dl...@hotmail.com>.
I have another quick question.

I have an AjaxDirectLink which can show/hide a div which contains form input 
components.  If the form inputs are visible and I then hide the box 
containing the form inputs then submit the form (regular tapestry submit)  I 
get null pointer errors everywhere, most likely because tapestry was 
expecting the components to be there.

Is there a good way around this?  The stack trace I get is pure tapestry 
engine calls and has nothing to do with my own code (not one reference to 
any of my packages)...

I guess I could always just set the div to hidden (via css), but the purpose 
was to save rendering time by not rendering the components at all when 
appropriate.

Thanks.

BTW keep up the work on Tacos, I'm really liking it, and it's very easy to 
use :)

----- Original Message ----- 
From: "Daniel Lydiard" <dl...@hotmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, March 03, 2006 10:53 AM
Subject: Tacos ajax direct link


> When i click on an AjaxDirectLink, I'm noticing in my log file that the 
> whole page is being re-rendered in the background, then the small 
> component i told AjaxDirectLink to update will update.
>
> So everything works, it just seems inneffecient, especially when it's 
> re-rendering my contrib:Table component when clicking on an Ajax link.
>
> Am i doing something wrong, or is this more of a Tapestry limitation?
>
> Thanks.
>
> 

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


Tacos ajax direct link

Posted by Daniel Lydiard <dl...@hotmail.com>.
When i click on an AjaxDirectLink, I'm noticing in my log file that the 
whole page is being re-rendered in the background, then the small component 
i told AjaxDirectLink to update will update.

So everything works, it just seems inneffecient, especially when it's 
re-rendering my contrib:Table component when clicking on an Ajax link.

Am i doing something wrong, or is this more of a Tapestry limitation?

Thanks.

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


Re: contrib:Table : advices requested

Posted by Andreas Bulling <sp...@phoenix.hadiko.de>.
Hi Daniel,

would you mind to provide some example code for your ITableColumnModel/
IBasicTableModel? Thanks a lot if this is possible!

Sincerly,
  Andreas


On 02. Feb 2006 - 10:59:16, Daniel Lydiard wrote:
| They way I got mine to work (I think my thread was the one you were 
| referring too) was initialize the table in pageAttached() and used @Persist 
| for the source/column getters.
| 
| So something like:
| @Persist
| public abstract ITableColumnModel getColumns()
| public abstract void setColumns(ITableColumnModel foo)
| 
| @Persist
| public abstract IBasicTableModel getTableModel()
| public abstract void setTableModel(IBasicTableModel bar)
| 
| Then in pageAttached (that's what I did) {
|  setColumns(new Foo());
|  setTableModel(new Bar());
| }
| 
| You could also initialize in some method like "activatePage" or whatever 
| and have a Link listener called the method to initialize the data.
| 
| I dunno if this is the proper way of doing things (I fairly new to 
| Tapestry), but it works for me with caching/no-caching modes.

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


Re: contrib:Table : advices requested

Posted by Daniel Lydiard <dl...@hotmail.com>.
They way I got mine to work (I think my thread was the one you were 
referring too) was initialize the table in pageAttached() and used @Persist 
for the source/column getters.

So something like:
@Persist
public abstract ITableColumnModel getColumns()
public abstract void setColumns(ITableColumnModel foo)

@Persist
public abstract IBasicTableModel getTableModel()
public abstract void setTableModel(IBasicTableModel bar)

Then in pageAttached (that's what I did) {
  setColumns(new Foo());
  setTableModel(new Bar());
}

You could also initialize in some method like "activatePage" or whatever and 
have a Link listener called the method to initialize the data.

I dunno if this is the proper way of doing things (I fairly new to 
Tapestry), but it works for me with caching/no-caching modes.


----- Original Message ----- 
From: "Martin Carel" <ma...@pricerunner.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, February 02, 2006 8:04 AM
Subject: Re: contrib:Table : advices requested


> Yes I did check those examples out. And indeed they were useful. And I 
> still have problems.
>
> This morning I realized I had forgotten to put my source's data property 
> persistent in the session.
>
> And bumped into another problem. Now I don't even see my table on the 
> first load, but have this exception:
> Either the tableModel parameter or both source and columns parameters must 
> be specified by component Results/resultsTable.tableView
>
> This issue has been discussed on this mailing-list, but I couldn't find a 
> solution to my problem so far :(
>
> My source is in an object called dOsList of type java.util.List.
> I lazy-initialize this object in its getter method.
> Thus my pageBeginRender() method is empty (the dOsList being null on first 
> load is handled by the getter).
> I have in my page specification <property name="dOsList" 
> persist="session"/>
> So that in my HTML template I have: source="ognl:dOsList" for my table 
> component.
>
> I know (with the debugger) that my getDOsList() on my page is *not* 
> called. I just can't figure out why.
> I can also see from the Tapestry exception page that my dOsList property 
> is not stored in the session.
>
> I call it a bad day. Any thoughts?
>
> /Martin
>
> Daniel Lydiard wrote:
>> Have you tried looking at these examples yet?
>>
>> https://tapestrywebcomponentexamples.dev.java.net/ 
>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war)
>>
>> There are a lot of help...
>>
>> ----- Original Message ----- From: "Martin Carel" 
>> <ma...@pricerunner.com>
>> To: "Tapestry users" <ta...@jakarta.apache.org>
>> Sent: Thursday, February 02, 2006 1:58 AM
>> Subject: contrib:Table : advices requested
>>
>>
>>> Hi folks!
>>>
>>> I'm using the contrib:Table for the first time. I'm using the source and 
>>> columns parameters (and therefore not the tableModel parameter).
>>>
>>> My source is a List of DOs, where each DO contains some fields (Date, 
>>> double, int, etc.) with getters.
>>>
>>> -- 
>>>
>>> Q1: My table does show up as expected, with the page navigation system. 
>>> But when I'm trying to change the page, I have this error:
>>>
>>> Failure invoking listener method 'public void 
>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>
>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>
>>> I have a similar error when I'm trying to sort a column. It really does 
>>> sound easy to solve, but I'm stuck.
>>>
>>> -- 
>>>
>>> Q2: I have a column which displays a price. So quite naturally the field 
>>> in my DO is a double. I want a string in front of my double, so I 
>>> figured I needed to have a column with a custom ColumnEvaluator. 
>>> Something like this:
>>>
>>>    public ITableColumn getPriceColumn() {
>>>        SimpleTableColumn priceColumn = new SimpleTableColumn("priceId",
>>>                "Price", new PriceColumnEvaluator(), true);
>>>        return priceColumn;
>>>    }
>>>
>>>    private static class PriceColumnEvaluator implements 
>>> ITableColumnEvaluator {    public Object getColumnValue(ITableColumn 
>>> objColumn, Object objRow) {
>>>            DO row = (DO) objRow;
>>>            String output = row.getCurrency() + " " + row.getPrice();
>>>            return output;
>>>        }
>>>    }
>>>
>>> However, I suspect my price sorting does not work anymore because now 
>>> the data type for my price column is a String (since my Evaluator 
>>> returns a String).  I was not comfortable with doing this formatting 
>>> thing (adding the currency sign) in my evaluator in the first place, 
>>> since it was not "pure data" stuff. Would you have implemented it 
>>> elsewhere?
>>>
>>> Related to this, I will need another column in which I'll have to 
>>> display a little picture (which will be a link) and a few other things. 
>>> Is using a customColumnEvaluator the preferred way to do it?
>>>
>>> Again, any hints appreciated.
>>>
>>> /Martin
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: contrib:Table : advices requested [bug identified]

Posted by Martin Carel <ma...@pricerunner.com>.
Hi!

I figured out the reason for my ArrayIndexOutOfBoundsException when 
clicking on the links (which are in fact DirectLink components) of the 
contrib:Table component, in an attempt to either paginate or sort a column.

In my application I have a servlet filter which filters all incoming 
requests and wraps them into a custom HttpRequest. Duringn this process, 
the filter takes all query strings parameters and put them into a Map. 
The DirectLink components of the contrib:Table component uses service 
parameters in order to know the component address and the column to 
sort. Those are service parameters (with the same parameter name "sp"). 
Therefore, because of the custom filter, only one parameter was kept 
(since a Map object uses unique keys) and thus the second parameter 
(with the same parameter name "sp") was lost and quite naturally could 
never reach the DirectLink's listener method (either the sorting one of 
the paginating one)!

Note: Earlier, I was concerned about porting the Tap3 contrib:Table 
examples 
(https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
to Tap4. No more concerns. The contrib:Table component does port to Tap4 
without problems.

Thank you for the help, again!

Best regards,

Martin Carel


Martin Carel wrote:
> Hi!
>
> Thanks again for the consideration and for the information about the 
> paging and sorting listeners being called before pageBeginRender().
> I did try what you proposed, but I have the same problem as before. On 
> first load, the table shows up as expected, but when paging or 
> sorting, I have the ArrayIndexOutOfBoundsException :(
>
> Note: even if the storedDOsList property was persistent in the 
> session, I couldn't see it in the HttpSession section of the Tapestry 
> exception page!
>
> I am still using a String to define my columns, and I will try to 
> define them using ITableColumnModel instead (as it seemed to work for 
> Daniel Lydiard). Let's see where it gets me... feel free to comment, 
> of course.
>
> Regards,
>
> Martin
>
> Mind Bridge wrote:
>> Hi,
>>
>> The reason for the problem is that the data is not provided using a 
>> true lazy loading, but is initializated in pageBeginRender instead. 
>> Since listeners are invoked before pageBeginRender (such as when the 
>> table paging or sorting changes), the data is not ready yet and 
>> problems occur.
>>
>> For the time being I would suggest to ignore pageBeginRender and 
>> write a method instead:
>> public List<DO> getStoredDOsList() {
>>  List<DO> data = getDOsList();
>>  if(data == null){
>>    data = //get my data;
>>    setDOsList(data);
>>  }
>>  return data;
>> }
>>
>> Then change your table component to use source="ognl:storedDOsList".
>>
>> Does this work?
>>
>>
>> Martin Carel wrote:
>>> Hi Mind Bridge,
>>>
>>> Thanks for the feedback. Here is my HTML template:
>>>
>>> <table jwcid="resultsTable@contrib:Table" source="ognl:DOsList"
>>>            columns="carId:Car:carName, =datesColumn, =priceColumn"
>>>            rowsClass="ognl:beans.evenOdd.next" pageSize="10"
>>>            initialSortColumn="priceId">
>>> </table>
>>>
>>> I tried to change a couple of things, since I was stuck. Now I'm 
>>> using @Persist for my DOsList property, instead of using 
>>> persist="session" in the page specification. And now I got my data 
>>> in my session (I got the coma-separated addresses of my DO-typed 
>>> objects within squared brakets on the Tapestry exception page - 
>>> normal since this is a List object).  I also now have an abstract 
>>> getter for my property, and I no more define the property per se. It 
>>> looks like this in the Java page:
>>>
>>> @Persist
>>> public abstract List<DO> getDOsList();
>>> public abstract void setDOsList(List<DO> dOsList);
>>>
>>> and it looks like this in my pageBeginRender(PageEvent event):
>>>
>>> if(getDOsList() == null){    setDOsList(//get my data);
>>> }
>>>
>>>
>>> Now I'm back with the ArrayOutOfBoundsException when I click on a 
>>> page or want to sort a column. The exception refers to line 183 of 
>>> org.apache.tapestry.contrib.table.components.TablePages (see below):
>>>
>>> 170             public void changePage(IRequestCycle objCycle)
>>> 171            {
>>> 172            Object[] arrParameters = 
>>> objCycle.getListenerParameters();
>>> 173            if (arrParameters.length != 2
>>> 174            && !(arrParameters[0] instanceof ComponentAddress)
>>> 175            && !(arrParameters[1] instanceof Integer))
>>> 176            {
>>> 177            // error
>>> 178            return;
>>> 179            }
>>> 180           181            ComponentAddress objAddress = 
>>> (ComponentAddress) arrParameters[0];
>>> 182            ITableModelSource objSource = (ITableModelSource) 
>>> objAddress.findComponent(objCycle);
>>> 183            setCurrentPage(objSource, ((Integer) 
>>> arrParameters[1]).intValue());
>>> 184           185            // ensure that the change is saved
>>> 186            objSource.fireObservedStateChange();
>>> 187            }
>>>
>>>
>>>
>>> > In addition you might want to check my answer to the recent 
>>> message "Table Model Question" from Nicholas Skriloff.
>>>
>>> Yep, I was aware of those issues (I spent the whole day trying to 
>>> resolve my problems). Thanks for the pointer anyways.
>>>
>>> It gets really frustrating, because this really seems like an easy 
>>> problem (ArrayOutOfBoundsException's have never given me a hard 
>>> time) :(
>>>
>>> /Martin
>>>
>>>
>>> Mind Bridge wrote:
>>>> Hi Martin,
>>>>
>>>> Is it possible to include the xml/html that define the Table 
>>>> component? Without that information it is a bit hard to see what is 
>>>> going on.
>>>>
>>>> In addition you might want to check my answer to the recent message 
>>>> "Table Model Question" from Nicholas Skriloff.
>>>>
>>>> Best regards,
>>>> -mb
>>>>
>>>> Martin Carel wrote:
>>>>> Yes I did check those examples out. And indeed they were useful. 
>>>>> And I still have problems.
>>>>>
>>>>> This morning I realized I had forgotten to put my source's data 
>>>>> property persistent in the session.
>>>>>
>>>>> And bumped into another problem. Now I don't even see my table on 
>>>>> the first load, but have this exception:
>>>>> Either the tableModel parameter or both source and columns 
>>>>> parameters must be specified by component 
>>>>> Results/resultsTable.tableView
>>>>>
>>>>> This issue has been discussed on this mailing-list, but I couldn't 
>>>>> find a solution to my problem so far :(
>>>>>
>>>>> My source is in an object called dOsList of type java.util.List.
>>>>> I lazy-initialize this object in its getter method.
>>>>> Thus my pageBeginRender() method is empty (the dOsList being null 
>>>>> on first load is handled by the getter).
>>>>> I have in my page specification <property name="dOsList" 
>>>>> persist="session"/>
>>>>> So that in my HTML template I have: source="ognl:dOsList" for my 
>>>>> table component.
>>>>>
>>>>> I know (with the debugger) that my getDOsList() on my page is 
>>>>> *not* called. I just can't figure out why.
>>>>> I can also see from the Tapestry exception page that my dOsList 
>>>>> property is not stored in the session.
>>>>>
>>>>> I call it a bad day. Any thoughts?
>>>>>
>>>>> /Martin
>>>>>
>>>>> Daniel Lydiard wrote:
>>>>>> Have you tried looking at these examples yet?
>>>>>>
>>>>>> https://tapestrywebcomponentexamples.dev.java.net/ 
>>>>>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>>>>>
>>>>>>
>>>>>> There are a lot of help...
>>>>>>
>>>>>> ----- Original Message ----- From: "Martin Carel" 
>>>>>> <ma...@pricerunner.com>
>>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>>> Sent: Thursday, February 02, 2006 1:58 AM
>>>>>> Subject: contrib:Table : advices requested
>>>>>>
>>>>>>
>>>>>>> Hi folks!
>>>>>>>
>>>>>>> I'm using the contrib:Table for the first time. I'm using the 
>>>>>>> source and columns parameters (and therefore not the tableModel 
>>>>>>> parameter).
>>>>>>>
>>>>>>> My source is a List of DOs, where each DO contains some fields 
>>>>>>> (Date, double, int, etc.) with getters.
>>>>>>>
>>>>>>> -- 
>>>>>>>
>>>>>>> Q1: My table does show up as expected, with the page navigation 
>>>>>>> system. But when I'm trying to change the page, I have this error:
>>>>>>>
>>>>>>> Failure invoking listener method 'public void 
>>>>>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>>>>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>>>>>
>>>>>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>>>>>
>>>>>>> I have a similar error when I'm trying to sort a column. It 
>>>>>>> really does sound easy to solve, but I'm stuck.
>>>>>>>
>>>>>>> -- 
>>>>>>>
>>>>>>> Q2: I have a column which displays a price. So quite naturally 
>>>>>>> the field in my DO is a double. I want a string in front of my 
>>>>>>> double, so I figured I needed to have a column with a custom 
>>>>>>> ColumnEvaluator. Something like this:
>>>>>>>
>>>>>>>    public ITableColumn getPriceColumn() {
>>>>>>>        SimpleTableColumn priceColumn = new 
>>>>>>> SimpleTableColumn("priceId",
>>>>>>>                "Price", new PriceColumnEvaluator(), true);
>>>>>>>        return priceColumn;
>>>>>>>    }
>>>>>>>
>>>>>>>    private static class PriceColumnEvaluator implements 
>>>>>>> ITableColumnEvaluator {    public Object 
>>>>>>> getColumnValue(ITableColumn objColumn, Object objRow) {
>>>>>>>            DO row = (DO) objRow;
>>>>>>>            String output = row.getCurrency() + " " + 
>>>>>>> row.getPrice();
>>>>>>>            return output;
>>>>>>>        }
>>>>>>>    }
>>>>>>>
>>>>>>> However, I suspect my price sorting does not work anymore 
>>>>>>> because now the data type for my price column is a String (since 
>>>>>>> my Evaluator returns a String).  I was not comfortable with 
>>>>>>> doing this formatting thing (adding the currency sign) in my 
>>>>>>> evaluator in the first place, since it was not "pure data" 
>>>>>>> stuff. Would you have implemented it elsewhere?
>>>>>>>
>>>>>>> Related to this, I will need another column in which I'll have 
>>>>>>> to display a little picture (which will be a link) and a few 
>>>>>>> other things. Is using a customColumnEvaluator the preferred way 
>>>>>>> to do it?
>>>>>>>
>>>>>>> Again, any hints appreciated.
>>>>>>>
>>>>>>> /Martin
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> 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
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: contrib:Table : advices requested

Posted by Martin Carel <ma...@pricerunner.com>.
Hi all!

I tried using the ITableColumnModel and it didn't change a thing (I 
still have the java.lang.ArrayIndexOutOfBoundsException).

I am under the impression it might be a Tapestry 4.0 issue, now that's 
the idea of my post.

I tried to run the code from 
https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war
The example uses Tapestry 3 with the libs in WEB-INF/libs and it works 
fine for me.

I tried to port it to Tapestry 4, and I had my 
java.lang.ArrayIndexOutOfBoundsException again!
The main issue with the port is to change the dataItems object from the 
Visit object (Tap3) to some other persistence strategy (Tap4). 
Otherwise, the rest of the code is quite simple and ports easily.

First I tried to put the dataItems object (the List object containing 
the data to be displayed) as persistent in the session (which is what I 
see as the best and required way to do), and then I tried to define it 
as a State Application Object (through hivemodule.xml) and injecting 
(@InjectState("dataItems")) it in FirstPass.java.

Both methods failed. On first load, everything is fine, but when sorting 
or paging, I got this java.lang.ArrayIndexOutOfBoundsException :(

If someone can have this example functional in Tapestry 4.0, I'd be 
*very* curious to see the code for it, as it does not work for me.

/M

Martin Carel wrote:
> Hi!
>
> Thanks again for the consideration and for the information about the 
> paging and sorting listeners being called before pageBeginRender().
> I did try what you proposed, but I have the same problem as before. On 
> first load, the table shows up as expected, but when paging or 
> sorting, I have the ArrayIndexOutOfBoundsException :(
>
> Note: even if the storedDOsList property was persistent in the 
> session, I couldn't see it in the HttpSession section of the Tapestry 
> exception page!
>
> I am still using a String to define my columns, and I will try to 
> define them using ITableColumnModel instead (as it seemed to work for 
> Daniel Lydiard). Let's see where it gets me... feel free to comment, 
> of course.
>
> Regards,
>
> Martin
>
> Mind Bridge wrote:
>> Hi,
>>
>> The reason for the problem is that the data is not provided using a 
>> true lazy loading, but is initializated in pageBeginRender instead. 
>> Since listeners are invoked before pageBeginRender (such as when the 
>> table paging or sorting changes), the data is not ready yet and 
>> problems occur.
>>
>> For the time being I would suggest to ignore pageBeginRender and 
>> write a method instead:
>> public List<DO> getStoredDOsList() {
>>  List<DO> data = getDOsList();
>>  if(data == null){
>>    data = //get my data;
>>    setDOsList(data);
>>  }
>>  return data;
>> }
>>
>> Then change your table component to use source="ognl:storedDOsList".
>>
>> Does this work?
>>
>>
>> Martin Carel wrote:
>>> Hi Mind Bridge,
>>>
>>> Thanks for the feedback. Here is my HTML template:
>>>
>>> <table jwcid="resultsTable@contrib:Table" source="ognl:DOsList"
>>>            columns="carId:Car:carName, =datesColumn, =priceColumn"
>>>            rowsClass="ognl:beans.evenOdd.next" pageSize="10"
>>>            initialSortColumn="priceId">
>>> </table>
>>>
>>> I tried to change a couple of things, since I was stuck. Now I'm 
>>> using @Persist for my DOsList property, instead of using 
>>> persist="session" in the page specification. And now I got my data 
>>> in my session (I got the coma-separated addresses of my DO-typed 
>>> objects within squared brakets on the Tapestry exception page - 
>>> normal since this is a List object).  I also now have an abstract 
>>> getter for my property, and I no more define the property per se. It 
>>> looks like this in the Java page:
>>>
>>> @Persist
>>> public abstract List<DO> getDOsList();
>>> public abstract void setDOsList(List<DO> dOsList);
>>>
>>> and it looks like this in my pageBeginRender(PageEvent event):
>>>
>>> if(getDOsList() == null){    setDOsList(//get my data);
>>> }
>>>
>>>
>>> Now I'm back with the ArrayOutOfBoundsException when I click on a 
>>> page or want to sort a column. The exception refers to line 183 of 
>>> org.apache.tapestry.contrib.table.components.TablePages (see below):
>>>
>>> 170             public void changePage(IRequestCycle objCycle)
>>> 171            {
>>> 172            Object[] arrParameters = 
>>> objCycle.getListenerParameters();
>>> 173            if (arrParameters.length != 2
>>> 174            && !(arrParameters[0] instanceof ComponentAddress)
>>> 175            && !(arrParameters[1] instanceof Integer))
>>> 176            {
>>> 177            // error
>>> 178            return;
>>> 179            }
>>> 180           181            ComponentAddress objAddress = 
>>> (ComponentAddress) arrParameters[0];
>>> 182            ITableModelSource objSource = (ITableModelSource) 
>>> objAddress.findComponent(objCycle);
>>> 183            setCurrentPage(objSource, ((Integer) 
>>> arrParameters[1]).intValue());
>>> 184           185            // ensure that the change is saved
>>> 186            objSource.fireObservedStateChange();
>>> 187            }
>>>
>>>
>>>
>>> > In addition you might want to check my answer to the recent 
>>> message "Table Model Question" from Nicholas Skriloff.
>>>
>>> Yep, I was aware of those issues (I spent the whole day trying to 
>>> resolve my problems). Thanks for the pointer anyways.
>>>
>>> It gets really frustrating, because this really seems like an easy 
>>> problem (ArrayOutOfBoundsException's have never given me a hard 
>>> time) :(
>>>
>>> /Martin
>>>
>>>
>>> Mind Bridge wrote:
>>>> Hi Martin,
>>>>
>>>> Is it possible to include the xml/html that define the Table 
>>>> component? Without that information it is a bit hard to see what is 
>>>> going on.
>>>>
>>>> In addition you might want to check my answer to the recent message 
>>>> "Table Model Question" from Nicholas Skriloff.
>>>>
>>>> Best regards,
>>>> -mb
>>>>
>>>> Martin Carel wrote:
>>>>> Yes I did check those examples out. And indeed they were useful. 
>>>>> And I still have problems.
>>>>>
>>>>> This morning I realized I had forgotten to put my source's data 
>>>>> property persistent in the session.
>>>>>
>>>>> And bumped into another problem. Now I don't even see my table on 
>>>>> the first load, but have this exception:
>>>>> Either the tableModel parameter or both source and columns 
>>>>> parameters must be specified by component 
>>>>> Results/resultsTable.tableView
>>>>>
>>>>> This issue has been discussed on this mailing-list, but I couldn't 
>>>>> find a solution to my problem so far :(
>>>>>
>>>>> My source is in an object called dOsList of type java.util.List.
>>>>> I lazy-initialize this object in its getter method.
>>>>> Thus my pageBeginRender() method is empty (the dOsList being null 
>>>>> on first load is handled by the getter).
>>>>> I have in my page specification <property name="dOsList" 
>>>>> persist="session"/>
>>>>> So that in my HTML template I have: source="ognl:dOsList" for my 
>>>>> table component.
>>>>>
>>>>> I know (with the debugger) that my getDOsList() on my page is 
>>>>> *not* called. I just can't figure out why.
>>>>> I can also see from the Tapestry exception page that my dOsList 
>>>>> property is not stored in the session.
>>>>>
>>>>> I call it a bad day. Any thoughts?
>>>>>
>>>>> /Martin
>>>>>
>>>>> Daniel Lydiard wrote:
>>>>>> Have you tried looking at these examples yet?
>>>>>>
>>>>>> https://tapestrywebcomponentexamples.dev.java.net/ 
>>>>>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>>>>>
>>>>>>
>>>>>> There are a lot of help...
>>>>>>
>>>>>> ----- Original Message ----- From: "Martin Carel" 
>>>>>> <ma...@pricerunner.com>
>>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>>> Sent: Thursday, February 02, 2006 1:58 AM
>>>>>> Subject: contrib:Table : advices requested
>>>>>>
>>>>>>
>>>>>>> Hi folks!
>>>>>>>
>>>>>>> I'm using the contrib:Table for the first time. I'm using the 
>>>>>>> source and columns parameters (and therefore not the tableModel 
>>>>>>> parameter).
>>>>>>>
>>>>>>> My source is a List of DOs, where each DO contains some fields 
>>>>>>> (Date, double, int, etc.) with getters.
>>>>>>>
>>>>>>> -- 
>>>>>>>
>>>>>>> Q1: My table does show up as expected, with the page navigation 
>>>>>>> system. But when I'm trying to change the page, I have this error:
>>>>>>>
>>>>>>> Failure invoking listener method 'public void 
>>>>>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>>>>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>>>>>
>>>>>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>>>>>
>>>>>>> I have a similar error when I'm trying to sort a column. It 
>>>>>>> really does sound easy to solve, but I'm stuck.
>>>>>>>
>>>>>>> -- 
>>>>>>>
>>>>>>> Q2: I have a column which displays a price. So quite naturally 
>>>>>>> the field in my DO is a double. I want a string in front of my 
>>>>>>> double, so I figured I needed to have a column with a custom 
>>>>>>> ColumnEvaluator. Something like this:
>>>>>>>
>>>>>>>    public ITableColumn getPriceColumn() {
>>>>>>>        SimpleTableColumn priceColumn = new 
>>>>>>> SimpleTableColumn("priceId",
>>>>>>>                "Price", new PriceColumnEvaluator(), true);
>>>>>>>        return priceColumn;
>>>>>>>    }
>>>>>>>
>>>>>>>    private static class PriceColumnEvaluator implements 
>>>>>>> ITableColumnEvaluator {    public Object 
>>>>>>> getColumnValue(ITableColumn objColumn, Object objRow) {
>>>>>>>            DO row = (DO) objRow;
>>>>>>>            String output = row.getCurrency() + " " + 
>>>>>>> row.getPrice();
>>>>>>>            return output;
>>>>>>>        }
>>>>>>>    }
>>>>>>>
>>>>>>> However, I suspect my price sorting does not work anymore 
>>>>>>> because now the data type for my price column is a String (since 
>>>>>>> my Evaluator returns a String).  I was not comfortable with 
>>>>>>> doing this formatting thing (adding the currency sign) in my 
>>>>>>> evaluator in the first place, since it was not "pure data" 
>>>>>>> stuff. Would you have implemented it elsewhere?
>>>>>>>
>>>>>>> Related to this, I will need another column in which I'll have 
>>>>>>> to display a little picture (which will be a link) and a few 
>>>>>>> other things. Is using a customColumnEvaluator the preferred way 
>>>>>>> to do it?
>>>>>>>
>>>>>>> Again, any hints appreciated.
>>>>>>>
>>>>>>> /Martin
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> 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
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: contrib:Table : advices requested

Posted by Martin Carel <ma...@pricerunner.com>.
Hi!

Thanks again for the consideration and for the information about the 
paging and sorting listeners being called before pageBeginRender().
I did try what you proposed, but I have the same problem as before. On 
first load, the table shows up as expected, but when paging or sorting, 
I have the ArrayIndexOutOfBoundsException :(

Note: even if the storedDOsList property was persistent in the session, 
I couldn't see it in the HttpSession section of the Tapestry exception page!

I am still using a String to define my columns, and I will try to define 
them using ITableColumnModel instead (as it seemed to work for Daniel 
Lydiard). Let's see where it gets me... feel free to comment, of course.

Regards,

Martin

Mind Bridge wrote:
> Hi,
>
> The reason for the problem is that the data is not provided using a 
> true lazy loading, but is initializated in pageBeginRender instead. 
> Since listeners are invoked before pageBeginRender (such as when the 
> table paging or sorting changes), the data is not ready yet and 
> problems occur.
>
> For the time being I would suggest to ignore pageBeginRender and write 
> a method instead:
> public List<DO> getStoredDOsList() {
>  List<DO> data = getDOsList();
>  if(data == null){
>    data = //get my data;
>    setDOsList(data);
>  }
>  return data;
> }
>
> Then change your table component to use source="ognl:storedDOsList".
>
> Does this work?
>
>
> Martin Carel wrote:
>> Hi Mind Bridge,
>>
>> Thanks for the feedback. Here is my HTML template:
>>
>> <table jwcid="resultsTable@contrib:Table" source="ognl:DOsList"
>>            columns="carId:Car:carName, =datesColumn, =priceColumn"
>>            rowsClass="ognl:beans.evenOdd.next" pageSize="10"
>>            initialSortColumn="priceId">
>> </table>
>>
>> I tried to change a couple of things, since I was stuck. Now I'm 
>> using @Persist for my DOsList property, instead of using 
>> persist="session" in the page specification. And now I got my data in 
>> my session (I got the coma-separated addresses of my DO-typed objects 
>> within squared brakets on the Tapestry exception page - normal since 
>> this is a List object).  I also now have an abstract getter for my 
>> property, and I no more define the property per se. It looks like 
>> this in the Java page:
>>
>> @Persist
>> public abstract List<DO> getDOsList();
>> public abstract void setDOsList(List<DO> dOsList);
>>
>> and it looks like this in my pageBeginRender(PageEvent event):
>>
>> if(getDOsList() == null){    setDOsList(//get my data);
>> }
>>
>>
>> Now I'm back with the ArrayOutOfBoundsException when I click on a 
>> page or want to sort a column. The exception refers to line 183 of 
>> org.apache.tapestry.contrib.table.components.TablePages (see below):
>>
>> 170             public void changePage(IRequestCycle objCycle)
>> 171            {
>> 172            Object[] arrParameters = 
>> objCycle.getListenerParameters();
>> 173            if (arrParameters.length != 2
>> 174            && !(arrParameters[0] instanceof ComponentAddress)
>> 175            && !(arrParameters[1] instanceof Integer))
>> 176            {
>> 177            // error
>> 178            return;
>> 179            }
>> 180           181            ComponentAddress objAddress = 
>> (ComponentAddress) arrParameters[0];
>> 182            ITableModelSource objSource = (ITableModelSource) 
>> objAddress.findComponent(objCycle);
>> 183            setCurrentPage(objSource, ((Integer) 
>> arrParameters[1]).intValue());
>> 184           185            // ensure that the change is saved
>> 186            objSource.fireObservedStateChange();
>> 187            }
>>
>>
>>
>> > In addition you might want to check my answer to the recent message 
>> "Table Model Question" from Nicholas Skriloff.
>>
>> Yep, I was aware of those issues (I spent the whole day trying to 
>> resolve my problems). Thanks for the pointer anyways.
>>
>> It gets really frustrating, because this really seems like an easy 
>> problem (ArrayOutOfBoundsException's have never given me a hard time) :(
>>
>> /Martin
>>
>>
>> Mind Bridge wrote:
>>> Hi Martin,
>>>
>>> Is it possible to include the xml/html that define the Table 
>>> component? Without that information it is a bit hard to see what is 
>>> going on.
>>>
>>> In addition you might want to check my answer to the recent message 
>>> "Table Model Question" from Nicholas Skriloff.
>>>
>>> Best regards,
>>> -mb
>>>
>>> Martin Carel wrote:
>>>> Yes I did check those examples out. And indeed they were useful. 
>>>> And I still have problems.
>>>>
>>>> This morning I realized I had forgotten to put my source's data 
>>>> property persistent in the session.
>>>>
>>>> And bumped into another problem. Now I don't even see my table on 
>>>> the first load, but have this exception:
>>>> Either the tableModel parameter or both source and columns 
>>>> parameters must be specified by component 
>>>> Results/resultsTable.tableView
>>>>
>>>> This issue has been discussed on this mailing-list, but I couldn't 
>>>> find a solution to my problem so far :(
>>>>
>>>> My source is in an object called dOsList of type java.util.List.
>>>> I lazy-initialize this object in its getter method.
>>>> Thus my pageBeginRender() method is empty (the dOsList being null 
>>>> on first load is handled by the getter).
>>>> I have in my page specification <property name="dOsList" 
>>>> persist="session"/>
>>>> So that in my HTML template I have: source="ognl:dOsList" for my 
>>>> table component.
>>>>
>>>> I know (with the debugger) that my getDOsList() on my page is *not* 
>>>> called. I just can't figure out why.
>>>> I can also see from the Tapestry exception page that my dOsList 
>>>> property is not stored in the session.
>>>>
>>>> I call it a bad day. Any thoughts?
>>>>
>>>> /Martin
>>>>
>>>> Daniel Lydiard wrote:
>>>>> Have you tried looking at these examples yet?
>>>>>
>>>>> https://tapestrywebcomponentexamples.dev.java.net/ 
>>>>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>>>>
>>>>>
>>>>> There are a lot of help...
>>>>>
>>>>> ----- Original Message ----- From: "Martin Carel" 
>>>>> <ma...@pricerunner.com>
>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>> Sent: Thursday, February 02, 2006 1:58 AM
>>>>> Subject: contrib:Table : advices requested
>>>>>
>>>>>
>>>>>> Hi folks!
>>>>>>
>>>>>> I'm using the contrib:Table for the first time. I'm using the 
>>>>>> source and columns parameters (and therefore not the tableModel 
>>>>>> parameter).
>>>>>>
>>>>>> My source is a List of DOs, where each DO contains some fields 
>>>>>> (Date, double, int, etc.) with getters.
>>>>>>
>>>>>> -- 
>>>>>>
>>>>>> Q1: My table does show up as expected, with the page navigation 
>>>>>> system. But when I'm trying to change the page, I have this error:
>>>>>>
>>>>>> Failure invoking listener method 'public void 
>>>>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>>>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>>>>
>>>>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>>>>
>>>>>> I have a similar error when I'm trying to sort a column. It 
>>>>>> really does sound easy to solve, but I'm stuck.
>>>>>>
>>>>>> -- 
>>>>>>
>>>>>> Q2: I have a column which displays a price. So quite naturally 
>>>>>> the field in my DO is a double. I want a string in front of my 
>>>>>> double, so I figured I needed to have a column with a custom 
>>>>>> ColumnEvaluator. Something like this:
>>>>>>
>>>>>>    public ITableColumn getPriceColumn() {
>>>>>>        SimpleTableColumn priceColumn = new 
>>>>>> SimpleTableColumn("priceId",
>>>>>>                "Price", new PriceColumnEvaluator(), true);
>>>>>>        return priceColumn;
>>>>>>    }
>>>>>>
>>>>>>    private static class PriceColumnEvaluator implements 
>>>>>> ITableColumnEvaluator {    public Object 
>>>>>> getColumnValue(ITableColumn objColumn, Object objRow) {
>>>>>>            DO row = (DO) objRow;
>>>>>>            String output = row.getCurrency() + " " + row.getPrice();
>>>>>>            return output;
>>>>>>        }
>>>>>>    }
>>>>>>
>>>>>> However, I suspect my price sorting does not work anymore because 
>>>>>> now the data type for my price column is a String (since my 
>>>>>> Evaluator returns a String).  I was not comfortable with doing 
>>>>>> this formatting thing (adding the currency sign) in my evaluator 
>>>>>> in the first place, since it was not "pure data" stuff. Would you 
>>>>>> have implemented it elsewhere?
>>>>>>
>>>>>> Related to this, I will need another column in which I'll have to 
>>>>>> display a little picture (which will be a link) and a few other 
>>>>>> things. Is using a customColumnEvaluator the preferred way to do it?
>>>>>>
>>>>>> Again, any hints appreciated.
>>>>>>
>>>>>> /Martin
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> 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
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>> ---------------------------------------------------------------------
>> 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


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


Re: contrib:Table : advices requested

Posted by Mind Bridge <mi...@yahoo.com>.
Hi,

The reason for the problem is that the data is not provided using a true 
lazy loading, but is initializated in pageBeginRender instead. Since 
listeners are invoked before pageBeginRender (such as when the table 
paging or sorting changes), the data is not ready yet and problems occur.

For the time being I would suggest to ignore pageBeginRender and write a 
method instead:
public List<DO> getStoredDOsList() {
  List<DO> data = getDOsList();
  if(data == null){
    data = //get my data;
    setDOsList(data);
  }
  return data;
}

Then change your table component to use source="ognl:storedDOsList".

Does this work?


Martin Carel wrote:
> Hi Mind Bridge,
>
> Thanks for the feedback. Here is my HTML template:
>
> <table jwcid="resultsTable@contrib:Table" source="ognl:DOsList"
>            columns="carId:Car:carName, =datesColumn, =priceColumn"
>            rowsClass="ognl:beans.evenOdd.next" pageSize="10"
>            initialSortColumn="priceId">
> </table>
>
> I tried to change a couple of things, since I was stuck. Now I'm using 
> @Persist for my DOsList property, instead of using persist="session" 
> in the page specification. And now I got my data in my session (I got 
> the coma-separated addresses of my DO-typed objects within squared 
> brakets on the Tapestry exception page - normal since this is a List 
> object).  I also now have an abstract getter for my property, and I no 
> more define the property per se. It looks like this in the Java page:
>
> @Persist
> public abstract List<DO> getDOsList();
> public abstract void setDOsList(List<DO> dOsList);
>
> and it looks like this in my pageBeginRender(PageEvent event):
>
> if(getDOsList() == null){    setDOsList(//get my data);
> }
>
>
> Now I'm back with the ArrayOutOfBoundsException when I click on a page 
> or want to sort a column. The exception refers to line 183 of 
> org.apache.tapestry.contrib.table.components.TablePages (see below):
>
> 170             public void changePage(IRequestCycle objCycle)
> 171            {
> 172            Object[] arrParameters = objCycle.getListenerParameters();
> 173            if (arrParameters.length != 2
> 174            && !(arrParameters[0] instanceof ComponentAddress)
> 175            && !(arrParameters[1] instanceof Integer))
> 176            {
> 177            // error
> 178            return;
> 179            }
> 180           181            ComponentAddress objAddress = 
> (ComponentAddress) arrParameters[0];
> 182            ITableModelSource objSource = (ITableModelSource) 
> objAddress.findComponent(objCycle);
> 183            setCurrentPage(objSource, ((Integer) 
> arrParameters[1]).intValue());
> 184           185            // ensure that the change is saved
> 186            objSource.fireObservedStateChange();
> 187            }
>
>
>
> > In addition you might want to check my answer to the recent message 
> "Table Model Question" from Nicholas Skriloff.
>
> Yep, I was aware of those issues (I spent the whole day trying to 
> resolve my problems). Thanks for the pointer anyways.
>
> It gets really frustrating, because this really seems like an easy 
> problem (ArrayOutOfBoundsException's have never given me a hard time) :(
>
> /Martin
>
>
> Mind Bridge wrote:
>> Hi Martin,
>>
>> Is it possible to include the xml/html that define the Table 
>> component? Without that information it is a bit hard to see what is 
>> going on.
>>
>> In addition you might want to check my answer to the recent message 
>> "Table Model Question" from Nicholas Skriloff.
>>
>> Best regards,
>> -mb
>>
>> Martin Carel wrote:
>>> Yes I did check those examples out. And indeed they were useful. And 
>>> I still have problems.
>>>
>>> This morning I realized I had forgotten to put my source's data 
>>> property persistent in the session.
>>>
>>> And bumped into another problem. Now I don't even see my table on 
>>> the first load, but have this exception:
>>> Either the tableModel parameter or both source and columns 
>>> parameters must be specified by component 
>>> Results/resultsTable.tableView
>>>
>>> This issue has been discussed on this mailing-list, but I couldn't 
>>> find a solution to my problem so far :(
>>>
>>> My source is in an object called dOsList of type java.util.List.
>>> I lazy-initialize this object in its getter method.
>>> Thus my pageBeginRender() method is empty (the dOsList being null on 
>>> first load is handled by the getter).
>>> I have in my page specification <property name="dOsList" 
>>> persist="session"/>
>>> So that in my HTML template I have: source="ognl:dOsList" for my 
>>> table component.
>>>
>>> I know (with the debugger) that my getDOsList() on my page is *not* 
>>> called. I just can't figure out why.
>>> I can also see from the Tapestry exception page that my dOsList 
>>> property is not stored in the session.
>>>
>>> I call it a bad day. Any thoughts?
>>>
>>> /Martin
>>>
>>> Daniel Lydiard wrote:
>>>> Have you tried looking at these examples yet?
>>>>
>>>> https://tapestrywebcomponentexamples.dev.java.net/ 
>>>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>>>
>>>>
>>>> There are a lot of help...
>>>>
>>>> ----- Original Message ----- From: "Martin Carel" 
>>>> <ma...@pricerunner.com>
>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>> Sent: Thursday, February 02, 2006 1:58 AM
>>>> Subject: contrib:Table : advices requested
>>>>
>>>>
>>>>> Hi folks!
>>>>>
>>>>> I'm using the contrib:Table for the first time. I'm using the 
>>>>> source and columns parameters (and therefore not the tableModel 
>>>>> parameter).
>>>>>
>>>>> My source is a List of DOs, where each DO contains some fields 
>>>>> (Date, double, int, etc.) with getters.
>>>>>
>>>>> -- 
>>>>>
>>>>> Q1: My table does show up as expected, with the page navigation 
>>>>> system. But when I'm trying to change the page, I have this error:
>>>>>
>>>>> Failure invoking listener method 'public void 
>>>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>>>
>>>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>>>
>>>>> I have a similar error when I'm trying to sort a column. It really 
>>>>> does sound easy to solve, but I'm stuck.
>>>>>
>>>>> -- 
>>>>>
>>>>> Q2: I have a column which displays a price. So quite naturally the 
>>>>> field in my DO is a double. I want a string in front of my double, 
>>>>> so I figured I needed to have a column with a custom 
>>>>> ColumnEvaluator. Something like this:
>>>>>
>>>>>    public ITableColumn getPriceColumn() {
>>>>>        SimpleTableColumn priceColumn = new 
>>>>> SimpleTableColumn("priceId",
>>>>>                "Price", new PriceColumnEvaluator(), true);
>>>>>        return priceColumn;
>>>>>    }
>>>>>
>>>>>    private static class PriceColumnEvaluator implements 
>>>>> ITableColumnEvaluator {    public Object 
>>>>> getColumnValue(ITableColumn objColumn, Object objRow) {
>>>>>            DO row = (DO) objRow;
>>>>>            String output = row.getCurrency() + " " + row.getPrice();
>>>>>            return output;
>>>>>        }
>>>>>    }
>>>>>
>>>>> However, I suspect my price sorting does not work anymore because 
>>>>> now the data type for my price column is a String (since my 
>>>>> Evaluator returns a String).  I was not comfortable with doing 
>>>>> this formatting thing (adding the currency sign) in my evaluator 
>>>>> in the first place, since it was not "pure data" stuff. Would you 
>>>>> have implemented it elsewhere?
>>>>>
>>>>> Related to this, I will need another column in which I'll have to 
>>>>> display a little picture (which will be a link) and a few other 
>>>>> things. Is using a customColumnEvaluator the preferred way to do it?
>>>>>
>>>>> Again, any hints appreciated.
>>>>>
>>>>> /Martin
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: contrib:Table : advices requested

Posted by Martin Carel <ma...@pricerunner.com>.
Hi Mind Bridge,

Thanks for the feedback. Here is my HTML template:

<table jwcid="resultsTable@contrib:Table" source="ognl:DOsList"
            columns="carId:Car:carName, =datesColumn, =priceColumn"
            rowsClass="ognl:beans.evenOdd.next" pageSize="10"
            initialSortColumn="priceId">
</table>

I tried to change a couple of things, since I was stuck. Now I'm using 
@Persist for my DOsList property, instead of using persist="session" in 
the page specification. And now I got my data in my session (I got the 
coma-separated addresses of my DO-typed objects within squared brakets 
on the Tapestry exception page - normal since this is a List object).  I 
also now have an abstract getter for my property, and I no more define 
the property per se. It looks like this in the Java page:

@Persist
public abstract List<DO> getDOsList();
public abstract void setDOsList(List<DO> dOsList);

and it looks like this in my pageBeginRender(PageEvent event):

if(getDOsList() == null){  
   setDOsList(//get my data);
}


Now I'm back with the ArrayOutOfBoundsException when I click on a page 
or want to sort a column. The exception refers to line 183 of 
org.apache.tapestry.contrib.table.components.TablePages (see below):

 170             public void changePage(IRequestCycle objCycle)
 171            {
 172            Object[] arrParameters = objCycle.getListenerParameters();
 173            if (arrParameters.length != 2
 174            && !(arrParameters[0] instanceof ComponentAddress)
 175            && !(arrParameters[1] instanceof Integer))
 176            {
 177            // error
 178            return;
 179            }
 180           
 181            ComponentAddress objAddress = (ComponentAddress) 
arrParameters[0];
 182            ITableModelSource objSource = (ITableModelSource) 
objAddress.findComponent(objCycle);
 183            setCurrentPage(objSource, ((Integer) 
arrParameters[1]).intValue());
 184           
 185            // ensure that the change is saved
 186            objSource.fireObservedStateChange();
 187            }



 > In addition you might want to check my answer to the recent message 
"Table Model Question" from Nicholas Skriloff.

Yep, I was aware of those issues (I spent the whole day trying to 
resolve my problems). Thanks for the pointer anyways.

It gets really frustrating, because this really seems like an easy 
problem (ArrayOutOfBoundsException's have never given me a hard time) :(

/Martin


Mind Bridge wrote:
> Hi Martin,
>
> Is it possible to include the xml/html that define the Table 
> component? Without that information it is a bit hard to see what is 
> going on.
>
> In addition you might want to check my answer to the recent message 
> "Table Model Question" from Nicholas Skriloff.
>
> Best regards,
> -mb
>
> Martin Carel wrote:
>> Yes I did check those examples out. And indeed they were useful. And 
>> I still have problems.
>>
>> This morning I realized I had forgotten to put my source's data 
>> property persistent in the session.
>>
>> And bumped into another problem. Now I don't even see my table on the 
>> first load, but have this exception:
>> Either the tableModel parameter or both source and columns parameters 
>> must be specified by component Results/resultsTable.tableView
>>
>> This issue has been discussed on this mailing-list, but I couldn't 
>> find a solution to my problem so far :(
>>
>> My source is in an object called dOsList of type java.util.List.
>> I lazy-initialize this object in its getter method.
>> Thus my pageBeginRender() method is empty (the dOsList being null on 
>> first load is handled by the getter).
>> I have in my page specification <property name="dOsList" 
>> persist="session"/>
>> So that in my HTML template I have: source="ognl:dOsList" for my 
>> table component.
>>
>> I know (with the debugger) that my getDOsList() on my page is *not* 
>> called. I just can't figure out why.
>> I can also see from the Tapestry exception page that my dOsList 
>> property is not stored in the session.
>>
>> I call it a bad day. Any thoughts?
>>
>> /Martin
>>
>> Daniel Lydiard wrote:
>>> Have you tried looking at these examples yet?
>>>
>>> https://tapestrywebcomponentexamples.dev.java.net/ 
>>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>>
>>>
>>> There are a lot of help...
>>>
>>> ----- Original Message ----- From: "Martin Carel" 
>>> <ma...@pricerunner.com>
>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>> Sent: Thursday, February 02, 2006 1:58 AM
>>> Subject: contrib:Table : advices requested
>>>
>>>
>>>> Hi folks!
>>>>
>>>> I'm using the contrib:Table for the first time. I'm using the 
>>>> source and columns parameters (and therefore not the tableModel 
>>>> parameter).
>>>>
>>>> My source is a List of DOs, where each DO contains some fields 
>>>> (Date, double, int, etc.) with getters.
>>>>
>>>> -- 
>>>>
>>>> Q1: My table does show up as expected, with the page navigation 
>>>> system. But when I'm trying to change the page, I have this error:
>>>>
>>>> Failure invoking listener method 'public void 
>>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>>
>>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>>
>>>> I have a similar error when I'm trying to sort a column. It really 
>>>> does sound easy to solve, but I'm stuck.
>>>>
>>>> -- 
>>>>
>>>> Q2: I have a column which displays a price. So quite naturally the 
>>>> field in my DO is a double. I want a string in front of my double, 
>>>> so I figured I needed to have a column with a custom 
>>>> ColumnEvaluator. Something like this:
>>>>
>>>>    public ITableColumn getPriceColumn() {
>>>>        SimpleTableColumn priceColumn = new 
>>>> SimpleTableColumn("priceId",
>>>>                "Price", new PriceColumnEvaluator(), true);
>>>>        return priceColumn;
>>>>    }
>>>>
>>>>    private static class PriceColumnEvaluator implements 
>>>> ITableColumnEvaluator {    public Object 
>>>> getColumnValue(ITableColumn objColumn, Object objRow) {
>>>>            DO row = (DO) objRow;
>>>>            String output = row.getCurrency() + " " + row.getPrice();
>>>>            return output;
>>>>        }
>>>>    }
>>>>
>>>> However, I suspect my price sorting does not work anymore because 
>>>> now the data type for my price column is a String (since my 
>>>> Evaluator returns a String).  I was not comfortable with doing this 
>>>> formatting thing (adding the currency sign) in my evaluator in the 
>>>> first place, since it was not "pure data" stuff. Would you have 
>>>> implemented it elsewhere?
>>>>
>>>> Related to this, I will need another column in which I'll have to 
>>>> display a little picture (which will be a link) and a few other 
>>>> things. Is using a customColumnEvaluator the preferred way to do it?
>>>>
>>>> Again, any hints appreciated.
>>>>
>>>> /Martin
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>> ---------------------------------------------------------------------
>> 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


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


Re: contrib:Table : advices requested

Posted by Mind Bridge <mi...@yahoo.com>.
Hi Martin,

Is it possible to include the xml/html that define the Table component? 
Without that information it is a bit hard to see what is going on.

In addition you might want to check my answer to the recent message 
"Table Model Question" from Nicholas Skriloff.

Best regards,
-mb

Martin Carel wrote:
> Yes I did check those examples out. And indeed they were useful. And I 
> still have problems.
>
> This morning I realized I had forgotten to put my source's data 
> property persistent in the session.
>
> And bumped into another problem. Now I don't even see my table on the 
> first load, but have this exception:
> Either the tableModel parameter or both source and columns parameters 
> must be specified by component Results/resultsTable.tableView
>
> This issue has been discussed on this mailing-list, but I couldn't 
> find a solution to my problem so far :(
>
> My source is in an object called dOsList of type java.util.List.
> I lazy-initialize this object in its getter method.
> Thus my pageBeginRender() method is empty (the dOsList being null on 
> first load is handled by the getter).
> I have in my page specification <property name="dOsList" 
> persist="session"/>
> So that in my HTML template I have: source="ognl:dOsList" for my table 
> component.
>
> I know (with the debugger) that my getDOsList() on my page is *not* 
> called. I just can't figure out why.
> I can also see from the Tapestry exception page that my dOsList 
> property is not stored in the session.
>
> I call it a bad day. Any thoughts?
>
> /Martin
>
> Daniel Lydiard wrote:
>> Have you tried looking at these examples yet?
>>
>> https://tapestrywebcomponentexamples.dev.java.net/ 
>> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>>
>>
>> There are a lot of help...
>>
>> ----- Original Message ----- From: "Martin Carel" 
>> <ma...@pricerunner.com>
>> To: "Tapestry users" <ta...@jakarta.apache.org>
>> Sent: Thursday, February 02, 2006 1:58 AM
>> Subject: contrib:Table : advices requested
>>
>>
>>> Hi folks!
>>>
>>> I'm using the contrib:Table for the first time. I'm using the source 
>>> and columns parameters (and therefore not the tableModel parameter).
>>>
>>> My source is a List of DOs, where each DO contains some fields 
>>> (Date, double, int, etc.) with getters.
>>>
>>> -- 
>>>
>>> Q1: My table does show up as expected, with the page navigation 
>>> system. But when I'm trying to change the page, I have this error:
>>>
>>> Failure invoking listener method 'public void 
>>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>>
>>> and that's an ArrayIndexOutOfBoundsException: 1.
>>>
>>> I have a similar error when I'm trying to sort a column. It really 
>>> does sound easy to solve, but I'm stuck.
>>>
>>> -- 
>>>
>>> Q2: I have a column which displays a price. So quite naturally the 
>>> field in my DO is a double. I want a string in front of my double, 
>>> so I figured I needed to have a column with a custom 
>>> ColumnEvaluator. Something like this:
>>>
>>>    public ITableColumn getPriceColumn() {
>>>        SimpleTableColumn priceColumn = new SimpleTableColumn("priceId",
>>>                "Price", new PriceColumnEvaluator(), true);
>>>        return priceColumn;
>>>    }
>>>
>>>    private static class PriceColumnEvaluator implements 
>>> ITableColumnEvaluator {    public Object getColumnValue(ITableColumn 
>>> objColumn, Object objRow) {
>>>            DO row = (DO) objRow;
>>>            String output = row.getCurrency() + " " + row.getPrice();
>>>            return output;
>>>        }
>>>    }
>>>
>>> However, I suspect my price sorting does not work anymore because 
>>> now the data type for my price column is a String (since my 
>>> Evaluator returns a String).  I was not comfortable with doing this 
>>> formatting thing (adding the currency sign) in my evaluator in the 
>>> first place, since it was not "pure data" stuff. Would you have 
>>> implemented it elsewhere?
>>>
>>> Related to this, I will need another column in which I'll have to 
>>> display a little picture (which will be a link) and a few other 
>>> things. Is using a customColumnEvaluator the preferred way to do it?
>>>
>>> Again, any hints appreciated.
>>>
>>> /Martin
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: contrib:Table : advices requested

Posted by Martin Carel <ma...@pricerunner.com>.
Yes I did check those examples out. And indeed they were useful. And I 
still have problems.

This morning I realized I had forgotten to put my source's data property 
persistent in the session.

And bumped into another problem. Now I don't even see my table on the 
first load, but have this exception:
Either the tableModel parameter or both source and columns parameters 
must be specified by component Results/resultsTable.tableView

This issue has been discussed on this mailing-list, but I couldn't find 
a solution to my problem so far :(

My source is in an object called dOsList of type java.util.List.
I lazy-initialize this object in its getter method.
Thus my pageBeginRender() method is empty (the dOsList being null on 
first load is handled by the getter).
I have in my page specification <property name="dOsList" persist="session"/>
So that in my HTML template I have: source="ognl:dOsList" for my table 
component.

I know (with the debugger) that my getDOsList() on my page is *not* 
called. I just can't figure out why.
I can also see from the Tapestry exception page that my dOsList property 
is not stored in the session.

I call it a bad day. Any thoughts?

/Martin

Daniel Lydiard wrote:
> Have you tried looking at these examples yet?
>
> https://tapestrywebcomponentexamples.dev.java.net/ 
> (https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war) 
>
>
> There are a lot of help...
>
> ----- Original Message ----- From: "Martin Carel" 
> <ma...@pricerunner.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, February 02, 2006 1:58 AM
> Subject: contrib:Table : advices requested
>
>
>> Hi folks!
>>
>> I'm using the contrib:Table for the first time. I'm using the source 
>> and columns parameters (and therefore not the tableModel parameter).
>>
>> My source is a List of DOs, where each DO contains some fields (Date, 
>> double, int, etc.) with getters.
>>
>> -- 
>>
>> Q1: My table does show up as expected, with the page navigation 
>> system. But when I'm trying to change the page, I have this error:
>>
>> Failure invoking listener method 'public void 
>> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
>> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>>
>> and that's an ArrayIndexOutOfBoundsException: 1.
>>
>> I have a similar error when I'm trying to sort a column. It really 
>> does sound easy to solve, but I'm stuck.
>>
>> -- 
>>
>> Q2: I have a column which displays a price. So quite naturally the 
>> field in my DO is a double. I want a string in front of my double, so 
>> I figured I needed to have a column with a custom ColumnEvaluator. 
>> Something like this:
>>
>>    public ITableColumn getPriceColumn() {
>>        SimpleTableColumn priceColumn = new SimpleTableColumn("priceId",
>>                "Price", new PriceColumnEvaluator(), true);
>>        return priceColumn;
>>    }
>>
>>    private static class PriceColumnEvaluator implements 
>> ITableColumnEvaluator {    public Object getColumnValue(ITableColumn 
>> objColumn, Object objRow) {
>>            DO row = (DO) objRow;
>>            String output = row.getCurrency() + " " + row.getPrice();
>>            return output;
>>        }
>>    }
>>
>> However, I suspect my price sorting does not work anymore because now 
>> the data type for my price column is a String (since my Evaluator 
>> returns a String).  I was not comfortable with doing this formatting 
>> thing (adding the currency sign) in my evaluator in the first place, 
>> since it was not "pure data" stuff. Would you have implemented it 
>> elsewhere?
>>
>> Related to this, I will need another column in which I'll have to 
>> display a little picture (which will be a link) and a few other 
>> things. Is using a customColumnEvaluator the preferred way to do it?
>>
>> Again, any hints appreciated.
>>
>> /Martin
>>
>>
>> ---------------------------------------------------------------------
>> 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


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


Re: contrib:Table : advices requested

Posted by Daniel Lydiard <dl...@hotmail.com>.
Have you tried looking at these examples yet?

https://tapestrywebcomponentexamples.dev.java.net/ 
(https://tapestrywebcomponentexamples.dev.java.net/files/documents/2449/8568/TapestryTables.war)

There are a lot of help...

----- Original Message ----- 
From: "Martin Carel" <ma...@pricerunner.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, February 02, 2006 1:58 AM
Subject: contrib:Table : advices requested


> Hi folks!
>
> I'm using the contrib:Table for the first time. I'm using the source and 
> columns parameters (and therefore not the tableModel parameter).
>
> My source is a List of DOs, where each DO contains some fields (Date, 
> double, int, etc.) with getters.
>
> --
>
> Q1: My table does show up as expected, with the page navigation system. 
> But when I'm trying to change the page, I have this error:
>
> Failure invoking listener method 'public void 
> org.apache.tapestry.contrib.table.components.TablePages.changePage(org.apache.tapestry.IRequestCycle)' 
> on $TablePages_302@12fe00a[Results/resultsTable.tablePages]: 1
>
> and that's an ArrayIndexOutOfBoundsException: 1.
>
> I have a similar error when I'm trying to sort a column. It really does 
> sound easy to solve, but I'm stuck.
>
> --
>
> Q2: I have a column which displays a price. So quite naturally the field 
> in my DO is a double. I want a string in front of my double, so I figured 
> I needed to have a column with a custom ColumnEvaluator. Something like 
> this:
>
>    public ITableColumn getPriceColumn() {
>        SimpleTableColumn priceColumn = new SimpleTableColumn("priceId",
>                "Price", new PriceColumnEvaluator(), true);
>        return priceColumn;
>    }
>
>    private static class PriceColumnEvaluator implements 
> ITableColumnEvaluator {    public Object getColumnValue(ITableColumn 
> objColumn, Object objRow) {
>            DO row = (DO) objRow;
>            String output = row.getCurrency() + " " + row.getPrice();
>            return output;
>        }
>    }
>
> However, I suspect my price sorting does not work anymore because now the 
> data type for my price column is a String (since my Evaluator returns a 
> String).  I was not comfortable with doing this formatting thing (adding 
> the currency sign) in my evaluator in the first place, since it was not 
> "pure data" stuff. Would you have implemented it elsewhere?
>
> Related to this, I will need another column in which I'll have to display 
> a little picture (which will be a link) and a few other things. Is using a 
> customColumnEvaluator the preferred way to do it?
>
> Again, any hints appreciated.
>
> /Martin
>
>
> ---------------------------------------------------------------------
> 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