myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vlad10 <ivla...@yahoo.com>
Subject Avoiding of writing a method per column in dataTable
Date Thu, 02 Aug 2007 18:05:48 GMT

I'm doing a sort by column on my dataTable, and want to display an image on
the column header when this column was choosen for the sorting. Say '>' -
for ascending and '<' - for descending (well, I'm using actual images). I'm
using on those images a rendered property pointed to a different method for
every column. What I hate about this approach that the only difference all
these methods have, they supply a hardcoded column name (what is another
deficiency to me) calling one common method. 
I'm looking for an idea of avoiding writing these multiple dummy wrappers.

Here is the fragment of my JSF page (just one column):

               <h:column>
                  <f:facet name="header">
		  <h:commandLink id="CustId" actionListener="#{basicScroller.sort}"
action="#" immediate="true">
                     <h:outputText value="#{msgs.customerIdHeader}"/>
                     <h:graphicImage url="/web/sec/images/arrow3.gif"
rendered="${basicScroller.sortAscId}"/>
                     <h:graphicImage url="/web/sec/images/arrow2.gif"
rendered="${basicScroller.sortDescId}"/>
		  </h:commandLink>
                  </f:facet>
                  <h:outputText value="#{customer.custId}"/>
               </h:column>

The methods:

    public boolean isSortAscId(){
        return isSortAsc("custId");
    }

    public boolean isSortDescId(){
        return isSortDesc("custId");
    }

May be I can grab those images as UIComponents from the sort() method
pointed by my commandLink actionListener? Still then I don't see how to
'desactivate' the previos image when clicking on a different column.
Or maybe this is just my deficiency in EL???

I'd appreciate all suggestions.

thanks
vlad
-- 
View this message in context: http://www.nabble.com/Avoiding-of-writing-a-method-per-column-in-dataTable-tf4207698.html#a11969568
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message