You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ken Clark <Ke...@pfizer.com> on 2007/06/18 19:50:17 UTC

Need to switch image depending on odd or even row in datatable


I have a t:datatable which is declared as:

<l:dataTable id="order_view"
             var="order"
             value="#{orderTable.dataModel}"
             first="#{orderTable.pageHandler.firstRowIndex}"
             rows="#{orderTable.noOfRows}"
             styleClass="dataTable"
             rowClasses="odd,even">

The odd and even styleclasses work fine.  However, I have an image on each
row, and because the background color changes, I need to use 2 different
icons.

How can I go about defining the output such that it uses a different icon
depending on whether the row is odd or even?

Thanks,
ken

-- 
View this message in context: http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11180728
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Need to switch image depending on odd or even row in datatable

Posted by Ken Clark <Ke...@pfizer.com>.
It turns out that the component change would be too time-consuming (and risky
-- we are two days from code freeze, just trying to clean up a few things.)  

It should have been obvious to me at the beginning how to do this -- I just
added a simple method to the underlying DataModel implementation and then
referenced that.

In the next release we will switch to extending the Tomahawk datatable. 
Thanks for the assistance!

Thanks,
ken


Mike Kienenberger wrote:
> 
> Extend org.apache.myfaces.component.html.ext.HtmlDataTable instead,
> and you should be set.
> 
> 
> On 6/18/07, Ken Clark <Ke...@pfizer.com> wrote:
>>
>> I think our problem is that we have build our own datatable extension
>> that I
>> thought was based on the Tomahawk datatable but is actually based on the
>> MyFaces baseline datatable implementation.
>>
>> Looking into switching that now...
>>
>> Thanks,
>> ken
>>
>>
>> Ken Clark wrote:
>> >
>> > Thanks for the quick reply.
>> >
>> > I tried that and got this error:
>> >
>> > javax.servlet.ServletException: Failed to compile JSP
>> > /order/viewOrdersTable.jsp
>> > viewOrdersTable.jsp:17:14: This attribute is not recognized.
>> >              rowIndexVar="_index"
>> >
>> > We are using tomahawk 1.1.3 -- is there a version dependency for
>> > rowIndexVar?
>> >
>> > Thanks,
>> > ken
>> >
>> >
>> > Christopher Cudennec wrote:
>> >>
>> >> Hi Ken,
>> >>
>> >> you can use attribute "rowIndexVar" for that. E.g.
>> >>
>> >> <t:dataTable rowIndexVar="_index" ...>
>> >>   #{_index % 2 == 0 ? 'even' : 'odd'}
>> >> </t:dataTable>
>> >>
>> >> see: http://myfaces.apache.org/tomahawk/extDataTable.html
>> >>
>> >> Cheers,
>> >>
>> >> Christopher
>> >>
>> >> Ken Clark schrieb:
>> >>> I have a t:datatable which is declared as:
>> >>>
>> >>> <l:dataTable id="order_view"
>> >>>              var="order"
>> >>>              value="#{orderTable.dataModel}"
>> >>>              first="#{orderTable.pageHandler.firstRowIndex}"
>> >>>              rows="#{orderTable.noOfRows}"
>> >>>              styleClass="dataTable"
>> >>>              rowClasses="odd,even">
>> >>>
>> >>> The odd and even styleclasses work fine.  However, I have an image on
>> >>> each
>> >>> row, and because the background color changes, I need to use 2
>> different
>> >>> icons.
>> >>>
>> >>> How can I go about defining the output such that it uses a different
>> >>> icon
>> >>> depending on whether the row is odd or even?
>> >>>
>> >>> Thanks,
>> >>> ken
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11182063
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11194092
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Need to switch image depending on odd or even row in datatable

Posted by Mike Kienenberger <mk...@gmail.com>.
Extend org.apache.myfaces.component.html.ext.HtmlDataTable instead,
and you should be set.


On 6/18/07, Ken Clark <Ke...@pfizer.com> wrote:
>
> I think our problem is that we have build our own datatable extension that I
> thought was based on the Tomahawk datatable but is actually based on the
> MyFaces baseline datatable implementation.
>
> Looking into switching that now...
>
> Thanks,
> ken
>
>
> Ken Clark wrote:
> >
> > Thanks for the quick reply.
> >
> > I tried that and got this error:
> >
> > javax.servlet.ServletException: Failed to compile JSP
> > /order/viewOrdersTable.jsp
> > viewOrdersTable.jsp:17:14: This attribute is not recognized.
> >              rowIndexVar="_index"
> >
> > We are using tomahawk 1.1.3 -- is there a version dependency for
> > rowIndexVar?
> >
> > Thanks,
> > ken
> >
> >
> > Christopher Cudennec wrote:
> >>
> >> Hi Ken,
> >>
> >> you can use attribute "rowIndexVar" for that. E.g.
> >>
> >> <t:dataTable rowIndexVar="_index" ...>
> >>   #{_index % 2 == 0 ? 'even' : 'odd'}
> >> </t:dataTable>
> >>
> >> see: http://myfaces.apache.org/tomahawk/extDataTable.html
> >>
> >> Cheers,
> >>
> >> Christopher
> >>
> >> Ken Clark schrieb:
> >>> I have a t:datatable which is declared as:
> >>>
> >>> <l:dataTable id="order_view"
> >>>              var="order"
> >>>              value="#{orderTable.dataModel}"
> >>>              first="#{orderTable.pageHandler.firstRowIndex}"
> >>>              rows="#{orderTable.noOfRows}"
> >>>              styleClass="dataTable"
> >>>              rowClasses="odd,even">
> >>>
> >>> The odd and even styleclasses work fine.  However, I have an image on
> >>> each
> >>> row, and because the background color changes, I need to use 2 different
> >>> icons.
> >>>
> >>> How can I go about defining the output such that it uses a different
> >>> icon
> >>> depending on whether the row is odd or even?
> >>>
> >>> Thanks,
> >>> ken
> >>>
> >>>
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11182063
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: Need to switch image depending on odd or even row in datatable

Posted by Ken Clark <Ke...@pfizer.com>.
I think our problem is that we have build our own datatable extension that I
thought was based on the Tomahawk datatable but is actually based on the
MyFaces baseline datatable implementation.

Looking into switching that now...

Thanks,
ken


Ken Clark wrote:
> 
> Thanks for the quick reply.  
> 
> I tried that and got this error:
>  
> javax.servlet.ServletException: Failed to compile JSP
> /order/viewOrdersTable.jsp
> viewOrdersTable.jsp:17:14: This attribute is not recognized.
>              rowIndexVar="_index"
> 
> We are using tomahawk 1.1.3 -- is there a version dependency for
> rowIndexVar?
> 
> Thanks,
> ken 
> 
> 
> Christopher Cudennec wrote:
>> 
>> Hi Ken,
>> 
>> you can use attribute "rowIndexVar" for that. E.g.
>> 
>> <t:dataTable rowIndexVar="_index" ...>
>>   #{_index % 2 == 0 ? 'even' : 'odd'}
>> </t:dataTable>
>> 
>> see: http://myfaces.apache.org/tomahawk/extDataTable.html
>> 
>> Cheers,
>> 
>> Christopher
>> 
>> Ken Clark schrieb:
>>> I have a t:datatable which is declared as:
>>>
>>> <l:dataTable id="order_view"
>>>              var="order"
>>>              value="#{orderTable.dataModel}"
>>>              first="#{orderTable.pageHandler.firstRowIndex}"
>>>              rows="#{orderTable.noOfRows}"
>>>              styleClass="dataTable"
>>>              rowClasses="odd,even">
>>>
>>> The odd and even styleclasses work fine.  However, I have an image on
>>> each
>>> row, and because the background color changes, I need to use 2 different
>>> icons.
>>>
>>> How can I go about defining the output such that it uses a different
>>> icon
>>> depending on whether the row is odd or even?
>>>
>>> Thanks,
>>> ken
>>>
>>>   
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11182063
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Need to switch image depending on odd or even row in datatable

Posted by Ken Clark <Ke...@pfizer.com>.
Thanks for the quick reply.  

I tried that and got this error:
 
javax.servlet.ServletException: Failed to compile JSP
/order/viewOrdersTable.jsp
viewOrdersTable.jsp:17:14: This attribute is not recognized.
             rowIndexVar="_index"

We are using tomahawk 1.1.3 -- is there a version dependency for
rowIndexVar?

Thanks,
ken 


Christopher Cudennec wrote:
> 
> Hi Ken,
> 
> you can use attribute "rowIndexVar" for that. E.g.
> 
> <t:dataTable rowIndexVar="_index" ...>
>   #{_index % 2 == 0 ? 'even' : 'odd'}
> </t:dataTable>
> 
> see: http://myfaces.apache.org/tomahawk/extDataTable.html
> 
> Cheers,
> 
> Christopher
> 
> Ken Clark schrieb:
>> I have a t:datatable which is declared as:
>>
>> <l:dataTable id="order_view"
>>              var="order"
>>              value="#{orderTable.dataModel}"
>>              first="#{orderTable.pageHandler.firstRowIndex}"
>>              rows="#{orderTable.noOfRows}"
>>              styleClass="dataTable"
>>              rowClasses="odd,even">
>>
>> The odd and even styleclasses work fine.  However, I have an image on
>> each
>> row, and because the background color changes, I need to use 2 different
>> icons.
>>
>> How can I go about defining the output such that it uses a different icon
>> depending on whether the row is odd or even?
>>
>> Thanks,
>> ken
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-in-datatable-tf3941849.html#a11181821
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Need to switch image depending on odd or even row in datatable

Posted by Christopher Cudennec <Sm...@gmx.net>.
Hi Ken,

you can use attribute "rowIndexVar" for that. E.g.

<t:dataTable rowIndexVar="_index" ...>
  #{_index % 2 == 0 ? 'even' : 'odd'}
</t:dataTable>

see: http://myfaces.apache.org/tomahawk/extDataTable.html

Cheers,

Christopher

Ken Clark schrieb:
> I have a t:datatable which is declared as:
>
> <l:dataTable id="order_view"
>              var="order"
>              value="#{orderTable.dataModel}"
>              first="#{orderTable.pageHandler.firstRowIndex}"
>              rows="#{orderTable.noOfRows}"
>              styleClass="dataTable"
>              rowClasses="odd,even">
>
> The odd and even styleclasses work fine.  However, I have an image on each
> row, and because the background color changes, I need to use 2 different
> icons.
>
> How can I go about defining the output such that it uses a different icon
> depending on whether the row is odd or even?
>
> Thanks,
> ken
>
>   


RE: Need to switch image depending on odd or even row in datatable

Posted by "Cormier, Matthieu" <ma...@abridean.com>.
Are you using a gif image?  Is using transparency an option?

M@

-----Original Message-----
From: Ken Clark [mailto:Ken.Clark@pfizer.com] 
Sent: Monday, June 18, 2007 2:50 PM
To: users@myfaces.apache.org
Subject: Need to switch image depending on odd or even row in datatable



I have a t:datatable which is declared as:

<l:dataTable id="order_view"
             var="order"
             value="#{orderTable.dataModel}"
             first="#{orderTable.pageHandler.firstRowIndex}"
             rows="#{orderTable.noOfRows}"
             styleClass="dataTable"
             rowClasses="odd,even">

The odd and even styleclasses work fine.  However, I have an image on
each
row, and because the background color changes, I need to use 2 different
icons.

How can I go about defining the output such that it uses a different
icon
depending on whether the row is odd or even?

Thanks,
ken

-- 
View this message in context:
http://www.nabble.com/Need-to-switch-image-depending-on-odd-or-even-row-
in-datatable-tf3941849.html#a11180728
Sent from the MyFaces - Users mailing list archive at Nabble.com.