You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Francesco Consumi <co...@istitutodeglinnocenti.it> on 2006/02/21 19:35:12 UTC

columns id

Hi,

we're using <t:columns> to show data from a query result.
We would need to assign an unique id to columns based on data field  
name, something like this:

<t:dataTable value="#{bean.rows}" var="g" ......>
         <t:columns  value="#{bean.columns}" var="col"  
styleClass="#{col.styleClass}">
       <f:facet name="header">
       <h:commandLink id="#{col.name}"  actionListener="#{bean.orderBy}">
                     <h:outputText value="#{col.label}"/>
                   </h:commandLink>
                 </f:facet>
                 <h:outputText value="#{g[col.name]}"/>
               </t:columns>
</t:dataTable>

but obviously it's impossible to set id as a jsf variable.

some idea to solve this problem ?
We need the ID of column in "orderBy" method for retrieving the field  
to be ordered.

-- 
Francesco Consumi
Ufficio Sistemi informativi
Istituto degli Innocenti
Piazza SS.Annunziata, 12
50122 Firenze
consumi at istitutodeglinnocenti.it
Tel. +39 055 2037320
ICQ# 12516133



Re: columns id

Posted by Mike Kienenberger <mk...@gmail.com>.
There is only one commandLink on your page, not one per column and row
(or #{bean.rows}" multiplied #{bean.columns} in your case).  If you
need to get the column name, you need to ask the t:columns component
for that information.

Use the binding attribute on your dataTable and your columns
components, and then do a "columns.getRowData()" [getRowData is NOT a
typo] to get the column object ("col") and "dataTable.getRowData()" to
get the row object ("g") inside your action method.   Probably
something like "((java.util.Map)dataTable.getRowData()).get(((COLUMN_TYPE)columns.getRowData()).getName())

On 2/21/06, Francesco Consumi <co...@istitutodeglinnocenti.it> wrote:
>
> Hi,
>
> we're using <t:columns> to show data from a query result.
> We would need to assign an unique id to columns based on data field
> name, something like this:
>
> <t:dataTable value="#{bean.rows}" var="g" ......>
>          <t:columns  value="#{bean.columns}" var="col"
> styleClass="#{col.styleClass}">
>        <f:facet name="header">
>        <h:commandLink id="#{col.name}"  actionListener="#{bean.orderBy}">
>                      <h:outputText value="#{col.label}"/>
>                    </h:commandLink>
>                  </f:facet>
>                  <h:outputText value="#{g[col.name]}"/>
>                </t:columns>
> </t:dataTable>
>
> but obviously it's impossible to set id as a jsf variable.
>
> some idea to solve this problem ?
> We need the ID of column in "orderBy" method for retrieving the field
> to be ordered.
>
> --
> Francesco Consumi
> Ufficio Sistemi informativi
> Istituto degli Innocenti
> Piazza SS.Annunziata, 12
> 50122 Firenze
> consumi at istitutodeglinnocenti.it
> Tel. +39 055 2037320
> ICQ# 12516133
>
>
>