开发者

Set rows in extendedDataTable as selected from backing bean

I wonder how I can programmaticly set rows in an ExtendedDataTable as selected from my backing bean. I need to edit a user in my web app. The user has some roles so what I want is that when the page is loaded the groups which the user has are selected in the extendedDataTable.

I'm using Spring3 with JSF 2 and richfaces 4.

I think I need to bind the table to a backing bean which is in request scope. Can I use the Spring request scope for that? After that I need to implement the walk开发者_Go百科() on the datatable I guess. I have no idea where to go from there, can somebody point me in the right direction or give me an example?

Regards,

Derk


Here a piece of my code. This works, I see the "rowdata equals object" log statement but now I need to say to the row "selected" but there isn't a method for that as far as I know... How can I accomplish this?

public void selectRows(){
          Collection<Object> s = new ArrayList<Object>(getGroups());
  log.debug("set the selection to the table");

          table.getTable().walk(FacesContext.getCurrentInstance(), new DataVisitor() {

  @Override
               public DataVisitResult process(FacesContext context, Object rowKey,
                         Object argument) {
  log.debug("entered walk");
                    Collection<Object> selection = (Collection<Object>) argument;
                    for(Object o : selection){
                         table.getTable().setRowKey(rowKey);
                         if(table.getTable().getRowData().equals(o)){
  log.debug("rowdata equals object");
                              table.getTable().getSelection().add(o);
                              log.debug("size of selection is: " + table.getTable().getSelection().size());
                         }
                    }
                    table.getTable().setRowKey(rowKey);
  return null;
               }
          }, s );
     }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜