Hi Gretta!

Thanks for your reply.
Please see my comments in-line below....

hi again Mike,

Mike <[EMAIL PROTECTED]> wrote on 12/30/2005 11:50:17 AM:

> Thanks for the info. I'm a little closer, but I'm still having problems.
>

>
>  <h:column>
>   f:facet name="header">
>   <t:commandSortHeader columnName="personName" arrow="true" >                
>     <h:outputText value="#{msgs.PersonName}" />
>       </t:commandSortHeader>                            
>      </f:facet>                                  
>     <h:outputText value="#{update.personName}" />
>    </h:column>
>
> I'd be almost done if I could just get clicking on the header to
> actually set the sortColumn property.
>
> Thanks again for any suggestions.
>
>     Mike

First, since you have a columnName as "personName", your sort method should have something like this:
if (column.equals("personName")) {
        return ascending ? c1.personName().compareTo(
                c2.getPersonName()) : c2.PersonName().compareTo(c1.PersonName());

Do you?
Yes.

My Sort method looks like this, but the strange thing is that it's not even being called until I remove the "#" that is being tacked on to the URL in in the browser after I click a column name.

Then it appears the problem is that the setSortColumn() method is not being called.

(I have the SortColumn equal to the class where the property and getter/setters are for that property so I don't know why this is still happening.)

   protected void sort(final String column, final boolean ascending)
   {
       
      Comparator comparator = new Comparator()
      {
          public int compare(Object o1, Object o2)
          {
             PersonDataItem c1 = (PersonDataItem)o1;
             PersonDataItem c2 = (PersonDataItem)o2;
            
              if (column == null)
              {
                   return 0;
              }
              if (column.equals("personName"))
              {     
                  return ascending ? c1.getPersonName().compareTo(c2.
getPersonName) : c2.getPersonName.compareTo(c1.getPersonName());
              }
        
              else return 0;
          }        
      };
      Collections.sort(_persons, comparator);
   }


I have most of the code you're referring to also, but the main problem is that when I click the column, the setColumnName method in the bean doesn't fire.

I'm also wondering about the value part of the table definition. It seems to be OK, but I'm running out of things to look at.

Mine is:  value ="#{TD.getPersons}" 

And, the corresponding getPersons() method looks like this (and this one is being called):

   public List getPersons()
   {
      try
      {
         this.loadFromDB();  // loads the ArrayList from Database.
      }
      catch (SQLException e)
      {
        
      }
       sort(getSortColumn(), isAscending());
      
      _persons= arrayListData;
      
       return _persons;
   }


Strange, huh?

    Mike

Reply via email to