You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Rush <sk...@gmail.com> on 2005/11/16 04:03:55 UTC
contrib table question - sort column by id NOT by value
Trying out contrib:Table for the first time... simple question (hopefully).
I have a table with the following columns:
Name - Status - Date
The Status column is represented in my object model as an object that
has an Integer Id field and a String description field.
I want to sort on the Id, but display the description in the table.
However the ITableColumnEvaluator only has one method to return a
value to both sort on and display... getColumnValue. Am I missing
something or is there a proper way to do this?
Cheers!
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: contrib table question - sort column by id NOT by value
Posted by Paul Rush <sk...@gmail.com>.
Gunna and tapestry list,
Again, thanks for the help. I wish the documentation was easier to
find. Turns out that the old 3.03 docs help quite a bit with
understanding tables, but I didn't realize that until today.
I just spent an additional 2 hours pounding my head against the wall
trying to get this to work until I realized that I wasn't calling:
statusColumn.loadSettings(this); which was preventing the id of the
column from being registered with the table (or however it works
internally), so @Block was being ignored.
contrib:Table is a tricky little beast. Assigning @Block's to ids by
appending the string "ColumnValue" also seems like a bad idea because
you have no feedback as to whether or not it's been bound correctly.
And, I know it's coming, but having a solid set of documentation would
greatly help, or a large array of examples.
So just in case anyone is following along at home, the code that works
looks like:
public ITableColumn getCurrentStatusColumn() {
SimpleTableColumn statusColumn =
new SimpleTableColumn("status", new
CurrentStatusColumnEvaluator(), true);
statusColumn.setColumnComparator(new StatusComparator());
statusColumn.loadSettings(this);
return statusColumn;
}
.. and ..
<table class="mytable" jwcid="table@contrib:Table"
source="ognl:allNotes"
columns="name, !description, dateCreated, =currentStatusColumn"
rowsClass="ognl:beans.evenOdd.next"
pageSize="20"
>
<span jwcid="statusColumnValue@Block"> f
<span jwcid="@Insert"
value="ognl:components.table.tableRow.currentStatus.description" />
</span>
Cheers,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: contrib table question - sort column by id NOT by value
Posted by Gunna Satria Hijrah Kusumah <gn...@nwa.iao.co.id>.
Hi Paul,
Sure it can.You can specify your column id in your column method.
there is a SimpleTableColumn's constructor that takes 3 parameters. column id,
column display name, and sort option
for example:
public ITableColumn getCurrentStatusColumn(){
SimpleTableColumn currentStatusColumn = new
SimpleTableColumn("statusId","Status",true);
...
}
So, you replace the value using
<span jwcid="statusIdColumnValue@Block">
...
regards,
Gunna
On Wednesday 16 November 2005 15:24, Paul Rush wrote:
...
> The code WAS working using a custom ColumnEvaluator and using
> =currentStatusColumn in the column definition but in that case there
> is no way to specific a @Block replacement because as far as I can
> tell =currentStatusColumn doesn't have an id. For example:
>
> <table class="mytable" jwcid="table@contrib:Table"
> source="ognl:allNotes"
> columns="name, !description, dateCreated, =currentStatusColumn" >
> <span jwcid="currentStatusColumn@Block">
> <span jwcid="@Insert"
> value="ognl:components.table.tableRow.currentStatus.status.id" />
> </span>
>
> This DOESN'T work. The @Block never gets referenced. This would be
> my preferred way to handle this situation, but I can't figure out how
> to link the @Block up to the column.
>
> Any further thoughts?
>
> Thanks again,
> Paul
>
> ---------------------------------------------------------------------
> 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 question - sort column by id NOT by value
Posted by Paul Rush <sk...@gmail.com>.
Thanks Gunna and Mind Bridge for the help! Definitely clarified my
usage of the table component. I have one more question about this...
If currentStatus (see my actual code at the bottom) sometimes returns
a null, the application throws a NullPointerException, which is
logical when attempting to access currentStatus.id when currentStatus
is null. Is there any way to make this work? As it is, very few of
my entites have status levels assigned so they are null. The important
parts of the code (as per MindBridge's suggestion):
columns="name, !description, dateCreated, currentStatus:currentStatus.id"
Will NOT work if currentStatus is occasionally null.
The code WAS working using a custom ColumnEvaluator and using
=currentStatusColumn in the column definition but in that case there
is no way to specific a @Block replacement because as far as I can
tell =currentStatusColumn doesn't have an id. For example:
<table class="mytable" jwcid="table@contrib:Table"
source="ognl:allNotes"
columns="name, !description, dateCreated, =currentStatusColumn" >
<span jwcid="currentStatusColumn@Block">
<span jwcid="@Insert"
value="ognl:components.table.tableRow.currentStatus.status.id" />
</span>
This DOESN'T work. The @Block never gets referenced. This would be
my preferred way to handle this situation, but I can't figure out how
to link the @Block up to the column.
Any further thoughts?
Thanks again,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: contrib table question - sort column by id NOT by value
Posted by Mind Bridge <mi...@yahoo.com>.
Hi,
Sorting:
the column is sorted using the OGNL expression provided in its
definition. For example 'status:id' will sort the status column by its id.
Display:
By default, the column displays the toString() of the value of the OGNL
expression above. If there is difference between sorting and display,
however, the display can be overridden by defining a Block in your page
with the name '<column id>ColumnValue' that defines how the column
should look like. For example:
<span jwcid="statusColumnValue@Block">
<span jwcid="@Insert"
value="ognl:components.table.tableRow.status.description"/>
</span>
This will display the field description in the status column, but the
sorting will be done as described above.
Paul Rush wrote:
> Trying out contrib:Table for the first time... simple question (hopefully).
>
> I have a table with the following columns:
>
> Name - Status - Date
>
> The Status column is represented in my object model as an object that
> has an Integer Id field and a String description field.
>
> I want to sort on the Id, but display the description in the table.
> However the ITableColumnEvaluator only has one method to return a
> value to both sort on and display... getColumnValue. Am I missing
> something or is there a proper way to do this?
>
> Cheers!
>
> Paul
>
> ---------------------------------------------------------------------
> 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 question - sort column by id NOT by value
Posted by Gunna Satria Hijrah Kusumah <gn...@nwa.iao.co.id>.
Hi,
you can add "=" expression in your table's columns definition and later
define your own custom column.
<static-binding name="columns" value="name,=statusColumn,date"/>
public ITableColumn getStatusColumn(){
SimpleTableColumn statusColumn = ....
statusColumn.setColumnComparator(yourComparator)...
return statusColumn;
}
i got this in TapestryTables. I forgot the site but it is contributed by John
Reynolds.
regards,
Gunna
On Wednesday 16 November 2005 10:03, Paul Rush wrote:
> Trying out contrib:Table for the first time... simple question (hopefully).
>
> I have a table with the following columns:
>
> Name - Status - Date
>
> The Status column is represented in my object model as an object that
> has an Integer Id field and a String description field.
>
> I want to sort on the Id, but display the description in the table.
> However the ITableColumnEvaluator only has one method to return a
> value to both sort on and display... getColumnValue. Am I missing
> something or is there a proper way to do this?
>
> Cheers!
>
> Paul
>
> ---------------------------------------------------------------------
> 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