0 Replies Latest reply on Aug 27, 2008 3:22 PM by john w75

    panelMenu/panelBar datatable

    john w75 Newbie

      Hi @ all,

      <rich:panelMenu binding="#{testingBean.panelMenu}" />
      <rich:panelBar binding="#{testingBean.panelBar}" />

      I'am testing a panelMenu or panelBar to insert an datatable which is filled by an collection. I successfully inserted a datatable in an panelBarItem oder PanelMenuItem; datatable shows the correct rows and columns, but not the values of each column. My second problem is that i can't select the datatable to edit a row.

      The Idea of this small project is to get an expandable table with richfaces, which habe dynamic values from a database.

      A small cut of the code:

      FacesContext facesContext = FacesContext.getCurrentInstance();
      ELContext elContext = facesContext.getELContext();
      Application application = facesContext.getApplication();
      ExpressionFactory elFactory = facesContext.getApplication()
      .getExpressionFactory();

      setPanelMenu(panelMenu);
      getPanelMenu().setId("panelMenu");
      getPanelMenu().setMode("ajax"); getPanelMenu().setIconExpandedTopGroup("/images/process/minus16.png");
      getPanelMenu().setIconCollapsedTopGroup("/images/process/plus16.png");
      getPanelMenu().setIconGroupTopPosition("left");

      int count = 0;
      List panelList = getPanelMenu().getChildren();

      for (TemplateGroupVO groupItem : serviceTemplate
      .getProcessTemplatesGrouped()) {

      HtmlPanelMenuGroup panelMenuGroup = new HtmlPanelMenuGroup();
      panelMenuGroup.setId("panelMenuGroupItem" + count );
      panelMenuGroup.setLabel(groupItem.getVertragsart() + " ("
      + groupItem.getTemplateGroupSize() + ")");
      panelMenuGroup.setData(groupItem);
      panelMenuGroup.setRendered(true);

      List panelMenuGroupList = panelMenuGroup.getChildren();
      HtmlPanelMenuItem panelMenuItem = new HtmlPanelMenuItem();
      panelMenuItem.setId("panelMenuItem" + zaehler);
      panelMenuItem.setRendered(true);
      panelMenuItem.setIcon("/images/process/x.gif");

      List templateVOList = new ArrayList();

      for (TemplateVO menuItem : groupItem.getTemplateGroup()) {
      TemplateVO templateVO = new TemplateVO();
      templateVO.setId(menuItem.getId());

      ...
      templateVOList.add(templateVO);
      }

      String[] columns = new String[] { "id", ...};
      String[] valueExp = new String[] { "#{templateVO.id}",..};

      HtmlDataTable datatable = new HtmlDataTable();
      datatable.setValue(templateVOList);
      datatable.setCellpadding("4");
      datatable.setCellpadding("4");
      datatable.setWidth("100%");
      datatable.setSortMode("Single");

      for (int i = 0; i < columns.length; i++) {
      HtmlOutputText header = new HtmlOutputText();
      header.setValue(columns);

      HtmlOutputText content = new HtmlOutputText();
      ValueExpression valueExpression = elFactory
      createValueExpression(elContext, valueExp
      ,
      String.class);
      content.setValueExpression("value", valueExpression);

      HtmlColumn column = new HtmlColumn();
      column.setId("col" + i);
      column.setHeader(header);
      column.getChildren().add(content);
      column.setSortBy(valueExp);
      column.setSortable(true);
      column.setSelfSorted(true);
      datatable.getChildren().add(column);
      }

      panelMenuItem.setId("datatable" + count);
      panelMenuItem.getChildren().add(datatable);

      panelMenuGroupList.add(panelMenuItem);

      panelList.add(panelMenuGroup);
      count++;
      }


      Can somebody help me?

      thanks.