You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Carl Marcum <ca...@codebuilders.net> on 2009/10/17 00:09:41 UTC
Issue with TableView using ListAdapter
Hi all,
I'm trying to set up an editable TableView based on table data from a
ListAdapter backed by a java.util.ArrayList from a JPA query.
I've done away with the JPA query portion and tested different ways to
build the TableView to find the problem.
The problem is the table doesn't seem to edit correctly or fire
RowEdited events when I use a ListAdapter to add table data.
For this example I'm creating "Customer" objects containing an int "id"
and a String "name" property.
If I:
1) build the pivot ArrayList in WTKX = ok.
2) build the pivot ArrayList in Java and add it via
tableView.addTableData = ok.
3) build a java.util.ArrayList (like I would get from a JPA query)
and create a Pivot ListAdapter then add that with tableView.addTableData
= problem
I can create an java.util.ArarryList, and add them one at a time to the
Pivot ArrayList and then use it for the table data = ok
Am I misunderstanding the use of ListAdapter to wrap a Java List or use
an Adapter for a TableView?
Thanks,
Carl Marcum
Re: Issue with TableView using ListAdapter
Posted by Carl Marcum <ca...@codebuilders.net>.
Greg,
Thanks, I built new jars from the trunk. The new code works great.
To build my example I had to modify my copy of CustomTableRow from the
demo due to a change in CalendarDate, but I see that has been taken care
of in the new demo version.
// for reference - setDate now uses a static CalendarDate.forString method.
public final void setDate(String calendarDate) {
setDate(CalendarDate.forString(calendarDate));
}
Thanks again,
Carl
Greg Brown wrote:
> I think I have located the problem. If you are building the platform
> from SVN, can you get the latest and try your code again?
> Thanks,
> Greg
>
> On Oct 19, 2009, at 8:48 PM, Carl Marcum wrote:
>
>> Greg,
>>
>> The problem I had is in the behavior of the table when using the
>> ListAdapter.
>> The table doesn't seem to update properly. Example when editing a text
>> field and hitting enter. Nothing happens.
>> Clicking out of the table, nothing.
>> I have since noticed if I hit 'esc' I do get an update.
>> If instead of using a ListAdapter, I use a pivot ArrayList and copy the
>> objects into it. Then in turn use the pivot ArrayList
>> The table edits normally.
>>
>> I'll modify the demo RowEditor as an example:
>>
>> demo.wtkx - remove all the hard coded tableData.
>>
>> RowEditorDemo.java - add the following above the line
>> 'window.open(display);'
>>
>> java.util.ArrayList<CustomTableRow> utilList =
>> new java.util.ArrayList<CustomTableRow>();
>>
>> CustomTableRow row1 = new CustomTableRow();
>> row1.setDate("2009-03-28");
>> row1.setType("Travel");
>> row1.setAmount("1286.90");
>> row1.setDescription("Ticket #145-XX-71903-09");
>> utilList.add(row1);
>>
>> CustomTableRow row2 = new CustomTableRow();
>> row2.setDate("2009-03-28");
>> row2.setType("Meals");
>> row2.setAmount("34.12");
>> row2.setDescription("Took client out");
>> utilList.add(row2);
>>
>> ListAdapter adapter = new ListAdapter(utilList);
>>
>> tableView.setTableData(adapter);
>>
>> Thanks,
>>
>> Carl
>>
>>
>> Greg Brown wrote:
>>> Hi Carl,
>>> Using a ListAdapter as the table data should work OK. Can you provide
>>> a code sample that demonstrates more specifically what you are doing
>>> in #3 below?
>>> Thanks,
>>> Greg
>>>
>>>
>>> On Oct 16, 2009, at 6:09 PM, Carl Marcum wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm trying to set up an editable TableView based on table data from a
>>>> ListAdapter backed by a java.util.ArrayList from a JPA query.
>>>>
>>>> I've done away with the JPA query portion and tested different ways to
>>>> build the TableView to find the problem.
>>>>
>>>> The problem is the table doesn't seem to edit correctly or fire
>>>> RowEdited events when I use a ListAdapter to add table data.
>>>>
>>>> For this example I'm creating "Customer" objects containing an int
>>>> "id"
>>>> and a String "name" property.
>>>> If I:
>>>> 1) build the pivot ArrayList in WTKX = ok.
>>>> 2) build the pivot ArrayList in Java and add it via
>>>> tableView.addTableData = ok.
>>>> 3) build a java.util.ArrayList (like I would get from a JPA query)
>>>> and create a Pivot ListAdapter then add that with
>>>> tableView.addTableData
>>>> = problem
>>>>
>>>> I can create an java.util.ArarryList, and add them one at a time to
>>>> the
>>>> Pivot ArrayList and then use it for the table data = ok
>>>>
>>>> Am I misunderstanding the use of ListAdapter to wrap a Java List
>>>> or use
>>>> an Adapter for a TableView?
>>>>
>>>> Thanks,
>>>>
>>>> Carl Marcum
>>>
>>>
>
>
Re: Issue with TableView using ListAdapter
Posted by Greg Brown <gk...@mac.com>.
I think I have located the problem. If you are building the platform
from SVN, can you get the latest and try your code again?
Thanks,
Greg
On Oct 19, 2009, at 8:48 PM, Carl Marcum wrote:
> Greg,
>
> The problem I had is in the behavior of the table when using the
> ListAdapter.
> The table doesn't seem to update properly. Example when editing a text
> field and hitting enter. Nothing happens.
> Clicking out of the table, nothing.
> I have since noticed if I hit 'esc' I do get an update.
> If instead of using a ListAdapter, I use a pivot ArrayList and copy
> the
> objects into it. Then in turn use the pivot ArrayList
> The table edits normally.
>
> I'll modify the demo RowEditor as an example:
>
> demo.wtkx - remove all the hard coded tableData.
>
> RowEditorDemo.java - add the following above the line
> 'window.open(display);'
>
> java.util.ArrayList<CustomTableRow> utilList =
> new java.util.ArrayList<CustomTableRow>();
>
> CustomTableRow row1 = new CustomTableRow();
> row1.setDate("2009-03-28");
> row1.setType("Travel");
> row1.setAmount("1286.90");
> row1.setDescription("Ticket #145-XX-71903-09");
> utilList.add(row1);
>
> CustomTableRow row2 = new CustomTableRow();
> row2.setDate("2009-03-28");
> row2.setType("Meals");
> row2.setAmount("34.12");
> row2.setDescription("Took client out");
> utilList.add(row2);
>
> ListAdapter adapter = new ListAdapter(utilList);
>
> tableView.setTableData(adapter);
>
> Thanks,
>
> Carl
>
>
> Greg Brown wrote:
>> Hi Carl,
>> Using a ListAdapter as the table data should work OK. Can you provide
>> a code sample that demonstrates more specifically what you are doing
>> in #3 below?
>> Thanks,
>> Greg
>>
>>
>> On Oct 16, 2009, at 6:09 PM, Carl Marcum wrote:
>>
>>> Hi all,
>>>
>>> I'm trying to set up an editable TableView based on table data
>>> from a
>>> ListAdapter backed by a java.util.ArrayList from a JPA query.
>>>
>>> I've done away with the JPA query portion and tested different
>>> ways to
>>> build the TableView to find the problem.
>>>
>>> The problem is the table doesn't seem to edit correctly or fire
>>> RowEdited events when I use a ListAdapter to add table data.
>>>
>>> For this example I'm creating "Customer" objects containing an int
>>> "id"
>>> and a String "name" property.
>>> If I:
>>> 1) build the pivot ArrayList in WTKX = ok.
>>> 2) build the pivot ArrayList in Java and add it via
>>> tableView.addTableData = ok.
>>> 3) build a java.util.ArrayList (like I would get from a JPA query)
>>> and create a Pivot ListAdapter then add that with
>>> tableView.addTableData
>>> = problem
>>>
>>> I can create an java.util.ArarryList, and add them one at a time
>>> to the
>>> Pivot ArrayList and then use it for the table data = ok
>>>
>>> Am I misunderstanding the use of ListAdapter to wrap a Java List
>>> or use
>>> an Adapter for a TableView?
>>>
>>> Thanks,
>>>
>>> Carl Marcum
>>
>>
Re: Issue with TableView using ListAdapter
Posted by Carl Marcum <ca...@codebuilders.net>.
Greg,
The problem I had is in the behavior of the table when using the
ListAdapter.
The table doesn't seem to update properly. Example when editing a text
field and hitting enter. Nothing happens.
Clicking out of the table, nothing.
I have since noticed if I hit 'esc' I do get an update.
If instead of using a ListAdapter, I use a pivot ArrayList and copy the
objects into it. Then in turn use the pivot ArrayList
The table edits normally.
I'll modify the demo RowEditor as an example:
demo.wtkx - remove all the hard coded tableData.
RowEditorDemo.java - add the following above the line
'window.open(display);'
java.util.ArrayList<CustomTableRow> utilList =
new java.util.ArrayList<CustomTableRow>();
CustomTableRow row1 = new CustomTableRow();
row1.setDate("2009-03-28");
row1.setType("Travel");
row1.setAmount("1286.90");
row1.setDescription("Ticket #145-XX-71903-09");
utilList.add(row1);
CustomTableRow row2 = new CustomTableRow();
row2.setDate("2009-03-28");
row2.setType("Meals");
row2.setAmount("34.12");
row2.setDescription("Took client out");
utilList.add(row2);
ListAdapter adapter = new ListAdapter(utilList);
tableView.setTableData(adapter);
Thanks,
Carl
Greg Brown wrote:
> Hi Carl,
> Using a ListAdapter as the table data should work OK. Can you provide
> a code sample that demonstrates more specifically what you are doing
> in #3 below?
> Thanks,
> Greg
>
>
> On Oct 16, 2009, at 6:09 PM, Carl Marcum wrote:
>
>> Hi all,
>>
>> I'm trying to set up an editable TableView based on table data from a
>> ListAdapter backed by a java.util.ArrayList from a JPA query.
>>
>> I've done away with the JPA query portion and tested different ways to
>> build the TableView to find the problem.
>>
>> The problem is the table doesn't seem to edit correctly or fire
>> RowEdited events when I use a ListAdapter to add table data.
>>
>> For this example I'm creating "Customer" objects containing an int "id"
>> and a String "name" property.
>> If I:
>> 1) build the pivot ArrayList in WTKX = ok.
>> 2) build the pivot ArrayList in Java and add it via
>> tableView.addTableData = ok.
>> 3) build a java.util.ArrayList (like I would get from a JPA query)
>> and create a Pivot ListAdapter then add that with tableView.addTableData
>> = problem
>>
>> I can create an java.util.ArarryList, and add them one at a time to the
>> Pivot ArrayList and then use it for the table data = ok
>>
>> Am I misunderstanding the use of ListAdapter to wrap a Java List or use
>> an Adapter for a TableView?
>>
>> Thanks,
>>
>> Carl Marcum
>
>
Re: Issue with TableView using ListAdapter
Posted by Greg Brown <gk...@mac.com>.
Hi Carl,
Using a ListAdapter as the table data should work OK. Can you provide
a code sample that demonstrates more specifically what you are doing
in #3 below?
Thanks,
Greg
On Oct 16, 2009, at 6:09 PM, Carl Marcum wrote:
> Hi all,
>
> I'm trying to set up an editable TableView based on table data from a
> ListAdapter backed by a java.util.ArrayList from a JPA query.
>
> I've done away with the JPA query portion and tested different ways to
> build the TableView to find the problem.
>
> The problem is the table doesn't seem to edit correctly or fire
> RowEdited events when I use a ListAdapter to add table data.
>
> For this example I'm creating "Customer" objects containing an int
> "id"
> and a String "name" property.
> If I:
> 1) build the pivot ArrayList in WTKX = ok.
> 2) build the pivot ArrayList in Java and add it via
> tableView.addTableData = ok.
> 3) build a java.util.ArrayList (like I would get from a JPA query)
> and create a Pivot ListAdapter then add that with
> tableView.addTableData
> = problem
>
> I can create an java.util.ArarryList, and add them one at a time to
> the
> Pivot ArrayList and then use it for the table data = ok
>
> Am I misunderstanding the use of ListAdapter to wrap a Java List or
> use
> an Adapter for a TableView?
>
> Thanks,
>
> Carl Marcum
Re: Issue with TableView using ListAdapter
Posted by Greg Brown <gk...@mac.com>.
FYI, if you are using a ListAdapter, you need to be sure to only
modify the list via the adapter, not the source. Otherwise, the table
view won't get any update events and won't properly reflect your
changes...
G
On Oct 17, 2009, at 9:25 AM, Vicente de Rivera III wrote:
> I also tried using ListAdapter but I had the same situation. So I
> just have both
>
> Client c = new Client();
> jpaList.add(c);
> tableDataList.add(c);
>
>
> On Sat, Oct 17, 2009 at 6:09 AM, Carl Marcum <carl.marcum@codebuilders.net
> > wrote:
> Hi all,
>
> I'm trying to set up an editable TableView based on table data from a
> ListAdapter backed by a java.util.ArrayList from a JPA query.
>
> I've done away with the JPA query portion and tested different ways to
> build the TableView to find the problem.
>
> The problem is the table doesn't seem to edit correctly or fire
> RowEdited events when I use a ListAdapter to add table data.
>
> For this example I'm creating "Customer" objects containing an int
> "id"
> and a String "name" property.
> If I:
> 1) build the pivot ArrayList in WTKX = ok.
> 2) build the pivot ArrayList in Java and add it via
> tableView.addTableData = ok.
> 3) build a java.util.ArrayList (like I would get from a JPA query)
> and create a Pivot ListAdapter then add that with
> tableView.addTableData
> = problem
>
> I can create an java.util.ArarryList, and add them one at a time to
> the
> Pivot ArrayList and then use it for the table data = ok
>
> Am I misunderstanding the use of ListAdapter to wrap a Java List or
> use
> an Adapter for a TableView?
>
> Thanks,
>
> Carl Marcum
>
Re: Issue with TableView using ListAdapter
Posted by Vicente de Rivera III <th...@gmail.com>.
I also tried using ListAdapter but I had the same situation. So I just have
both
Client c = new Client();
jpaList.add(c);
tableDataList.add(c);
On Sat, Oct 17, 2009 at 6:09 AM, Carl Marcum
<ca...@codebuilders.net>wrote:
> Hi all,
>
> I'm trying to set up an editable TableView based on table data from a
> ListAdapter backed by a java.util.ArrayList from a JPA query.
>
> I've done away with the JPA query portion and tested different ways to
> build the TableView to find the problem.
>
> The problem is the table doesn't seem to edit correctly or fire
> RowEdited events when I use a ListAdapter to add table data.
>
> For this example I'm creating "Customer" objects containing an int "id"
> and a String "name" property.
> If I:
> 1) build the pivot ArrayList in WTKX = ok.
> 2) build the pivot ArrayList in Java and add it via
> tableView.addTableData = ok.
> 3) build a java.util.ArrayList (like I would get from a JPA query)
> and create a Pivot ListAdapter then add that with tableView.addTableData
> = problem
>
> I can create an java.util.ArarryList, and add them one at a time to the
> Pivot ArrayList and then use it for the table data = ok
>
> Am I misunderstanding the use of ListAdapter to wrap a Java List or use
> an Adapter for a TableView?
>
> Thanks,
>
> Carl Marcum
>