You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bravo Villegas Salvador Francisco <SB...@sigmatao.com> on 2008/05/30 19:53:49 UTC

[Tobago] Sorting problems

Hi All,

 

I'm having troubles with the sort of a sheet in Tobago.

But the info in the sheet doesn't get sorted by the column selected.

 

What can be the problem?

Any suggestion? 

 

In my JSP:

<tc:sheet ........... . . . . . 

      . . . . . . . .

      sortActionListener="#{accessBean.sheetSorter}">

<tc:column label="#{overviewBundle.userLoginUser}"

            id="userName" sortable="true" align="center">

 

In my Class:

public void sheetSorter(ActionEvent event) {

            if (event instanceof SortActionEvent) {

                  SortActionEvent sortEvent = (SortActionEvent) event;

                  UIData sheet = sortEvent.getSheet();

                  SheetState sheetState 

                        =
sheet.getSheetState(FacesContext.getCurrentInstance());

                  String columnId = sheetState.getSortedColumnId();

                  List<UserLogin> list = (List<UserLogin>)
sheet.getValue();

                  Comparator<UserLogin> comparator = null;

                  if ("userName".equals(columnId)) {

                        comparator = new Comparator<UserLogin>() {

                             public int compare(UserLogin o1, UserLogin
o2) {

                                   return
o1.getUserName().compareTo(o2.getUserName());

                             }

                        };

                  } 

                  Collections.sort(list, comparator);

                  for (Iterator iter = list.iterator(); iter.hasNext();)
{

 
System.out.println(iter.getClass().getName().toString());

                  }

                  if (!sheetState.isAscending()) {

                        Collections.reverse(list);

                  }

            }

 

 

Regards


Re: [Tobago] Sorting problems

Posted by Volker Weber <v....@inexso.de>.
Hi Slavador,

what is the implementation of sheets value valuebinding ?

in the sorter you do a sheet.getValue() wich invokes the valueBinding method,
and at rendering the sheet did again a getValue() and therefore
reinvoke this method.


Regards,
    Volker




2008/5/30 Bravo Villegas Salvador Francisco <SB...@sigmatao.com>:
> HI again
>
>
>
> I checked, and the problema is not the sorting method, it Works fine
>
> But the problems Is in the view, It doesn't refresh the list
>
> Ideas?
>
>
>
> ________________________________
>
> De: Bravo Villegas Salvador Francisco [mailto:SBRAVO@sigmatao.com]
> Enviado el: Viernes, 30 de Mayo de 2008 12:54 p.m.
> Para: MyFaces Discussion
> Asunto: [Tobago] Sorting problems
>
>
>
> Hi All,
>
>
>
> I'm having troubles with the sort of a sheet in Tobago.
>
> But the info in the sheet doesn't get sorted by the column selected.
>
>
>
> What can be the problem?
>
> Any suggestion?
>
>
>
> In my JSP:
>
> <tc:sheet ……….. . . . . .
>
>       . . . . . . . .
>
>       sortActionListener="#{accessBean.sheetSorter}">
>
> <tc:column label="#{overviewBundle.userLoginUser}"
>
>             id="userName" sortable="true" align="center">
>
>
>
> In my Class:
>
> public void sheetSorter(ActionEvent event) {
>
>             if (event instanceof SortActionEvent) {
>
>                   SortActionEvent sortEvent = (SortActionEvent) event;
>
>                   UIData sheet = sortEvent.getSheet();
>
>                   SheetState sheetState
>
>                         =
> sheet.getSheetState(FacesContext.getCurrentInstance());
>
>                   String columnId = sheetState.getSortedColumnId();
>
>                   List<UserLogin> list = (List<UserLogin>) sheet.getValue();
>
>                   Comparator<UserLogin> comparator = null;
>
>                   if ("userName".equals(columnId)) {
>
>                         comparator = new Comparator<UserLogin>() {
>
>                              public int compare(UserLogin o1, UserLogin o2)
> {
>
>                                    return
> o1.getUserName().compareTo(o2.getUserName());
>
>                              }
>
>                         };
>
>                   }
>
>                   Collections.sort(list, comparator);
>
>                   for (Iterator iter = list.iterator(); iter.hasNext();) {
>
>
> System.out.println(iter.getClass().getName().toString());
>
>                   }
>
>                   if (!sheetState.isAscending()) {
>
>                         Collections.reverse(list);
>
>                   }
>
>             }
>
>
>
>
>
> Regards



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13 | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX: +49 441 4082 355 | www.inexso.de

RE: [Tobago] Sorting problems

Posted by Bravo Villegas Salvador Francisco <SB...@sigmatao.com>.
HI again

 

I checked, and the problema is not the sorting method, it Works fine

But the problems Is in the view, It doesn't refresh the list

Ideas?

 

________________________________

De: Bravo Villegas Salvador Francisco [mailto:SBRAVO@sigmatao.com] 
Enviado el: Viernes, 30 de Mayo de 2008 12:54 p.m.
Para: MyFaces Discussion
Asunto: [Tobago] Sorting problems

 

Hi All,

 

I'm having troubles with the sort of a sheet in Tobago.

But the info in the sheet doesn't get sorted by the column selected.

 

What can be the problem?

Any suggestion? 

 

In my JSP:

<tc:sheet ........... . . . . . 

      . . . . . . . .

      sortActionListener="#{accessBean.sheetSorter}">

<tc:column label="#{overviewBundle.userLoginUser}"

            id="userName" sortable="true" align="center">

 

In my Class:

public void sheetSorter(ActionEvent event) {

            if (event instanceof SortActionEvent) {

                  SortActionEvent sortEvent = (SortActionEvent) event;

                  UIData sheet = sortEvent.getSheet();

                  SheetState sheetState 

                        =
sheet.getSheetState(FacesContext.getCurrentInstance());

                  String columnId = sheetState.getSortedColumnId();

                  List<UserLogin> list = (List<UserLogin>)
sheet.getValue();

                  Comparator<UserLogin> comparator = null;

                  if ("userName".equals(columnId)) {

                        comparator = new Comparator<UserLogin>() {

                             public int compare(UserLogin o1, UserLogin
o2) {

                                   return
o1.getUserName().compareTo(o2.getUserName());

                             }

                        };

                  } 

                  Collections.sort(list, comparator);

                  for (Iterator iter = list.iterator(); iter.hasNext();)
{

 
System.out.println(iter.getClass().getName().toString());

                  }

                  if (!sheetState.isAscending()) {

                        Collections.reverse(list);

                  }

            }

 

 

Regards