3 Replies Latest reply on May 23, 2011 6:33 AM by Murali Krishna

    java generated extendedDataTable inside modalPanel

    Bojan Nikcevic Newbie

      Richfaces 3.3.3

      Tomcat 7.0

       

      I'm having problem when generating rich:extendeddatatable inside modalPanel, and i'm doing this dynamicaly from java code. Here is the example:

       

       

      <h:panelGrid id="parametersGrid" columns="2"
                    styleClass="reportParametersGrid"
                    columnClasses="reportParameterLabel,reportParameterField"
                    binding="#{coreIzvestajController.parametriGrid}" />
      

       

      public UIComponent createModalPanel(ModalPanelParameters modalPanelParameters) {
              String name = modalPanelParameters.getName();
              String id = name+"LovModalPanel";
              String nameVeliko = getStringUtil().prvoSlovoVeliko(name);
              String header = "coreLabela"+nameVeliko+"LovModalPanelHeader";
              String tableName = "tabela"+nameVeliko;
              String controller = name+"SelectionController";
              String datamodel = name+"DataTableModelApi";
              String tableValue = controller+"."+datamodel;
              String tableAction = controller+".handleSelection";
              String dugmeId = name+"DugmeOdaberi";
              
              HtmlModalPanel htmlModalPanel = new HtmlModalPanel();
              htmlModalPanel.setId(id);
              htmlModalPanel.setAutosized(true);
              htmlModalPanel.setResizeable(false);
              htmlModalPanel.setMoveable(true);
              htmlModalPanel.setMinWidth(600);
              
              Map<String, UIComponent> facets = htmlModalPanel.getFacets();
              HtmlOutputText htmlOutputText = new HtmlOutputText();
              htmlOutputText.setValue(getMessage(header));
              facets.put("header", htmlOutputText);
              
              HtmlHotKey htmlHotKey = new HtmlHotKey();
              htmlHotKey.setKey("backspace");
              htmlHotKey.setHandler("return false;");
              htmlHotKey.setDisableInInput(true);
              htmlModalPanel.getChildren().add(htmlHotKey);
              
              HtmlExtendedDataTable htmlExtendedDataTable = new HtmlExtendedDataTable();
              htmlExtendedDataTable.setId(tableName);
              htmlExtendedDataTable.setStyle("margin: auto;");
              htmlExtendedDataTable.setHeight("310px");
              htmlExtendedDataTable.setWidth("800px");
              htmlExtendedDataTable.setRows(10);
              htmlExtendedDataTable.setEnableContextMenu(false);
              htmlExtendedDataTable.setNoDataLabel(getMessage("commonNoDataLabel"));
              htmlExtendedDataTable.setValueExpression("value", createValueExpresion(tableValue,OsbOsobaDataTableModelApi.class));
              htmlExtendedDataTable.setVar(name);
              
              htmlExtendedDataTable.setSortMode("single");
              htmlExtendedDataTable.setSelectionMode("single");
              htmlExtendedDataTable.setValueExpression("selection", createValueExpresion("coreIzvestajController.selection", SimpleSelection.class));
              htmlExtendedDataTable.setRowKeyVar("rkvar");
              htmlExtendedDataTable.setValueExpression("tableState", createValueExpresion("coreIzvestajController.tableState"));
              
              HtmlAjaxSupport htmlAjaxSupport = new HtmlAjaxSupport();
              htmlAjaxSupport.setEvent("onRowClick");
              htmlAjaxSupport.setActionExpression(createExpresion(tableAction));
              htmlAjaxSupport.setReRender(dugmeId);
              htmlExtendedDataTable.getChildren().add(htmlAjaxSupport);
              
              HtmlColumn htmlColumn = new HtmlColumn();
              htmlColumn.setId("column1ime");
              htmlColumn.setWidth("50%");
              
              HtmlOutputText columnLabel = new HtmlOutputText();
              columnLabel.setValue("ime");
              htmlColumn.setHeader(columnLabel);
              
              HtmlOutputText htmlOutputText2 = new HtmlOutputText();
              String value = name+".ime";
              htmlOutputText2.setValueExpression("value", createValueExpresion(value));
              
              htmlColumn.getChildren().add(htmlOutputText2);
              
              htmlExtendedDataTable.getChildren().add(htmlColumn);
              
              HtmlColumn htmlColumn2 = new HtmlColumn();
              htmlColumn2.setId("column1ime");
              htmlColumn2.setWidth("50%");
              
              HtmlOutputText columnLabel2 = new HtmlOutputText();
              columnLabel2.setValue("prezime");
              htmlColumn2.setHeader(columnLabel2);
              
              HtmlOutputText htmlOutputText3 = new HtmlOutputText();
              String value2 = name+".prezime";
              htmlOutputText3.setValueExpression("value", createValueExpresion(value2));
              
              htmlColumn2.getChildren().add(htmlOutputText3);
              
              htmlExtendedDataTable.getChildren().add(htmlColumn2);
              htmlModalPanel.getChildren().add(htmlExtendedDataTable);
              
              
              HtmlSpacer spacer = new HtmlSpacer();
              spacer.setWidth("5");
              htmlPanelGroup.getChildren().add(spacer);
              
              HtmlAjaxCommandButton odustaniCommandButton = new HtmlAjaxCommandButton();
              odustaniCommandButton.setStyleClass("button buttonImageCancel");
              odustaniCommandButton.setValue(getMessage("common_odustani"));
              odustaniCommandButton.setOnclick("Richfaces.hideModalPanel('"+id+"');");
              htmlPanelGroup.getChildren().add(odustaniCommandButton);
              
              htmlModalPanel.getChildren().add(htmlPanelGroup);
              
              return htmlModalPanel;
          }
      

       

      Exception:

       

       

      java.lang.NullPointerException
          at org.richfaces.component.ColumnsOrder.getColumnIndex(ExtendedDataTableState.java:425)
          at org.richfaces.component.ColumnsOrder.access$000(ExtendedDataTableState.java:347)
          at org.richfaces.component.ColumnsOrder$1.compare(ExtendedDataTableState.java:475)
          at org.richfaces.component.ColumnsOrder$1.compare(ExtendedDataTableState.java:474)
          at java.util.Arrays.mergeSort(Arrays.java:1270)
          at java.util.Arrays.sort(Arrays.java:1210)
          at java.util.Collections.sort(Collections.java:159)
          at org.richfaces.component.ColumnsOrder.sortColumns(ExtendedDataTableState.java:473)
          at org.richfaces.component.ExtendedDataTableState.sortColumns(ExtendedDataTableState.java:144)
          at org.richfaces.component.UIExtendedDataTable.getSortedChildren(UIExtendedDataTable.java:150)
          at org.richfaces.component.SortedColumnsIterator.<init>(SortedColumnsIterator.java:41)
          at org.richfaces.component.UIExtendedDataTable.getSortedColumns(UIExtendedDataTable.java:134)
          at org.richfaces.renderkit.AbstractExtendedTableRenderer.encodeColumns(AbstractExtendedTableRenderer.java:130)
          at org.richfaces.renderkit.html.ExtendedDataTableRenderer.doEncodeBegin(ExtendedDataTableRenderer.java:262)
          at org.richfaces.renderkit.html.ExtendedDataTableRenderer.doEncodeBegin(ExtendedDataTableRenderer.java:196)
          at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:100)
          at org.richfaces.renderkit.AbstractExtendedTableRenderer.encodeBegin(AbstractExtendedTableRenderer.java:1365)
          at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
          at javax.faces.component.UIData.encodeBegin(UIData.java:962)
          at org.ajax4jsf.component.UIDataAdaptorBase.encodeBegin(UIDataAdaptorBase.java:1225)
          at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
          at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
          at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
          at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
          at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:368)
          at org.richfaces.renderkit.html.ModalPanelRenderer.doEncodeChildren(ModalPanelRenderer.java:363)
          at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
          at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
          at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
          at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:239)
          at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
          at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
           ...
      

       

      The problem seems to be when processing columns for datatable because plain table whithout columns is displayed properly. Also if i put the same code for datatable outside modal panel, the table and columns are also displayed fine !

      Any ideas ?