You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Petter Måhlén <pe...@elevance.se> on 2004/03/16 15:57:26 UTC

Contrib:table question

Hi,

I tried the following in a page specification:

  <component id="taskTable" type="contrib:Table" >
    <binding name="source" expression="taskList" />
    <static-binding name="columns" value="customer:Kund:customerName,
name:Projektnamn:fullTaskName, state:Status:getStateLabel(state), !delete"
/>
  </component>

The getStateLabel() method is defined in the page class and simply maps an
integer to a a string. This doesn't work, since OGNL is not able to find a
method in the page class. I tried (just to see what would happen) to change
it to page.getStateLabel(), but that doesn't work either. A look in the code
suggested that that is due to the fact that OGNL is given a generic object
to check for properties - maybe some AbstractTableRow class could be defined
that contained a getPage() method? That is, unless there is a better way to
do what I would like to do: the mapping from an integer to a string? Even if
there is, could it be useful to access methods in the page class from a
column definition?

Another (minor) thing is the fact that even though there was an
OGNLException for each row in the table, this only shows up in the log, not
in the form of an exception page being shown to the user. For myself, I
prefer getting my errors right in my face, so I would have preferred the
org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator.getCol
umnValue() method (sometimes Java really has wonderful names) to just pass
on the exception rather than log the message and return an empty string. But
maybe that would cause other problems?

/ Petter


---------------------------------------------------------------------
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

Posted by Petter Måhlén <pe...@elevance.se>.
That worked like a charm, thanks!

/ Petter

> -----Original Message-----
> From: Mind Bridge [mailto:mindbridgeweb@yahoo.com] 
> Sent: den 16 mars 2004 16:23
> To: Tapestry users
> Subject: RE: Contrib:table question
> 
> 
> Hi Petter,
> 
> The OGNL expressions are evaluated with respect to the row 
> object currently
> being displayed. Some of your other columns, for example, use 
> expressions
> like 'fullTaskName', which are executed on your row objects, 
> as expected,
> rather than the page.
> 
> There are a number of ways to do what you desire, but I think 
> this one is
> the simplest:
> 
> Make the column definition to be:
> state:Status:state
> 
> This will make the column to be sorted by the numerical value 
> of 'state'
> rather than its string representation.
> 
> Also, add the following to your page template:
> 
> <span jwcid="stateColumnValue@Block">
> 	<span jwcid="@Insert"
> value="ognl:getStateLabel(components.taskTable.tableRow.state)"/>
> </span>
> 
> This will make the state render in the table using the string
> representation.
> 
> No other changes are necessary.
> 
> -mb
> 
> -----Original Message-----
> From: Petter Måhlén [mailto:petter.mahlen@elevance.se]
> Sent: Tuesday, March 16, 2004 4:57 PM
> To: Tapestry-User
> Subject: Contrib:table question
> 
> 
> Hi,
> 
> I tried the following in a page specification:
> 
>   <component id="taskTable" type="contrib:Table" >
>     <binding name="source" expression="taskList" />
>     <static-binding name="columns" value="customer:Kund:customerName,
> name:Projektnamn:fullTaskName, 
> state:Status:getStateLabel(state), !delete"
> />
>   </component>
> 
> The getStateLabel() method is defined in the page class and 
> simply maps an
> integer to a a string. This doesn't work, since OGNL is not 
> able to find a
> method in the page class. I tried (just to see what would 
> happen) to change
> it to page.getStateLabel(), but that doesn't work either. A 
> look in the code
> suggested that that is due to the fact that OGNL is given a 
> generic object
> to check for properties - maybe some AbstractTableRow class 
> could be defined
> that contained a getPage() method? That is, unless there is a 
> better way to
> do what I would like to do: the mapping from an integer to a 
> string? Even if
> there is, could it be useful to access methods in the page 
> class from a
> column definition?
> 
> Another (minor) thing is the fact that even though there was an
> OGNLException for each row in the table, this only shows up 
> in the log, not
> in the form of an exception page being shown to the user. For 
> myself, I
> prefer getting my errors right in my face, so I would have 
> preferred the
> org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEv
> aluator.getCol
> umnValue() method (sometimes Java really has wonderful names) 
> to just pass
> on the exception rather than log the message and return an 
> empty string. But
> maybe that would cause other problems?
> 
> / Petter
> 
> 
> ---------------------------------------------------------------------
> 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 question

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

The OGNL expressions are evaluated with respect to the row object currently
being displayed. Some of your other columns, for example, use expressions
like 'fullTaskName', which are executed on your row objects, as expected,
rather than the page.

There are a number of ways to do what you desire, but I think this one is
the simplest:

Make the column definition to be:
state:Status:state

This will make the column to be sorted by the numerical value of 'state'
rather than its string representation.

Also, add the following to your page template:

<span jwcid="stateColumnValue@Block">
	<span jwcid="@Insert"
value="ognl:getStateLabel(components.taskTable.tableRow.state)"/>
</span>

This will make the state render in the table using the string
representation.

No other changes are necessary.

-mb

-----Original Message-----
From: Petter Måhlén [mailto:petter.mahlen@elevance.se]
Sent: Tuesday, March 16, 2004 4:57 PM
To: Tapestry-User
Subject: Contrib:table question


Hi,

I tried the following in a page specification:

  <component id="taskTable" type="contrib:Table" >
    <binding name="source" expression="taskList" />
    <static-binding name="columns" value="customer:Kund:customerName,
name:Projektnamn:fullTaskName, state:Status:getStateLabel(state), !delete"
/>
  </component>

The getStateLabel() method is defined in the page class and simply maps an
integer to a a string. This doesn't work, since OGNL is not able to find a
method in the page class. I tried (just to see what would happen) to change
it to page.getStateLabel(), but that doesn't work either. A look in the code
suggested that that is due to the fact that OGNL is given a generic object
to check for properties - maybe some AbstractTableRow class could be defined
that contained a getPage() method? That is, unless there is a better way to
do what I would like to do: the mapping from an integer to a string? Even if
there is, could it be useful to access methods in the page class from a
column definition?

Another (minor) thing is the fact that even though there was an
OGNLException for each row in the table, this only shows up in the log, not
in the form of an exception page being shown to the user. For myself, I
prefer getting my errors right in my face, so I would have preferred the
org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator.getCol
umnValue() method (sometimes Java really has wonderful names) to just pass
on the exception rather than log the message and return an empty string. But
maybe that would cause other problems?

/ Petter


---------------------------------------------------------------------
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