@Override
   protected StaticXmlWidget createDataTableComponent(String elementName, Map<String, String> attributes,
            StaticXmlMetawidget metawidget)
   {
      // Create the normal table

      StaticXmlWidget dataTable = super.createDataTableComponent(elementName, attributes, metawidget);
      dataTable.putAttribute("styleClass", "data-table");

      // Process the binding and id early, so we can use them below

      StandardBindingProcessor bindingProcessor = metawidget.getWidgetProcessor(StandardBindingProcessor.class);

      if (bindingProcessor != null)
      {
         bindingProcessor.processWidget(dataTable, elementName, attributes, (StaticUIMetawidget) metawidget);
      }

      ReadableIdProcessor readableIdProcessor = metawidget.getWidgetProcessor(ReadableIdProcessor.class);

      if (readableIdProcessor != null)
      {
         readableIdProcessor.processWidget(dataTable, elementName, attributes, metawidget);
      }

      ValueHolder valueHolderTable = (ValueHolder) dataTable;
      String tableValueExpression = valueHolderTable.getValue();

      // Special support for non-Lists

      Class<?> clazz = WidgetBuilderUtils.getActualClassOrType(attributes, null);

      if (!List.class.isAssignableFrom(clazz))
      {
         String asListValueExpression = "forgeview:asList(" + StaticFacesUtils.unwrapExpression(tableValueExpression)
                  + ")";
         valueHolderTable.setValue(StaticFacesUtils.wrapExpression(asListValueExpression));
         ((BaseStaticXmlWidget) dataTable).putAdditionalNamespaceURI("forgeview", "http://jboss.org/forge/view");
      }

      // Add row creation/deletion for OneToMany and ManyToMany

      if (!TRUE.equals(attributes.get(N_TO_MANY)) || metawidget.isReadOnly())
      {
         return dataTable;
      }

      String componentType = WidgetBuilderUtils.getComponentType(attributes);

      if (componentType == null)
      {
         return dataTable;
      }

      // Hack until https://issues.apache.org/jira/browse/MYFACES-3410 is resolved: move the Collection into a temporary
      // variable

      HtmlPanelGroup panelGroup = new HtmlPanelGroup();

      FaceletsParam param = new FaceletsParam();
      param.putAttribute("name", COLLECTION_VAR);
      param.putAttribute("value", tableValueExpression);
      panelGroup.getChildren().add(param);

      // Special support for non-Lists

      if (!List.class.isAssignableFrom(clazz))
      {
         valueHolderTable.setValue(StaticFacesUtils.wrapExpression("forgeview:asList(" + COLLECTION_VAR + ")"));
      }
      else
      {
         valueHolderTable.setValue(StaticFacesUtils.wrapExpression(COLLECTION_VAR));
      }

      panelGroup.getChildren().add(dataTable);

      // If not bidirectional, create an 'Add' section (bidirectional does it 'in place')

      if (!attributes.containsKey(INVERSE_RELATIONSHIP))
      {
         HtmlPanelGrid panelGrid = new HtmlPanelGrid();
         panelGrid.putAttribute("styleClass", "data-table-footer");
         panelGrid.putAttribute("columns", "2");
         panelGrid.putAttribute("columnClasses", ",remove-column");

         // Select menu at bottom

         HtmlSelectOneMenu select = new HtmlSelectOneMenu();
         String selectId = dataTable.getAttribute("id") + "Select";
         select.putAttribute("id", selectId);
         String requestScopedValue = "requestScope['" + selectId + "']";
         select.setValue(StaticFacesUtils.wrapExpression(requestScopedValue));
         String simpleComponentType = ClassUtils.getSimpleName(componentType);
         String controllerName = StringUtils.decapitalize(simpleComponentType);
         select.setConverter(StaticFacesUtils.wrapExpression(controllerName + "Bean.converter"));
         addSelectItems(select, StaticFacesUtils.wrapExpression(controllerName + "Bean.all"), attributes);
         panelGrid.getChildren().add(select);

         // Create 'Add' button

         HtmlCommandLink addLink = new HtmlCommandLink();
         addLink.putAttribute("styleClass", "add-button");
         String addExpression = COLLECTION_VAR + ".add(" + requestScopedValue + ")";
         addLink.putAttribute("action", StaticFacesUtils.wrapExpression(addExpression));
         addLink.putAttribute("onclick", "if (document.getElementById(document.forms[0].id+':" + selectId
                  + "').selectedIndex &lt; 1) { alert('Must select a " + StringUtils.uncamelCase(simpleComponentType)
                  + "'); return false; }");

         // (id is useful for unit tests)

         addLink.putAttribute("id", dataTable.getAttribute("id") + "Add");
         panelGrid.getChildren().add(addLink);

         panelGroup.getChildren().add(panelGrid);
      }

      return panelGroup;
   }
@ Override protected StaticXmlWidget createDataTableComponent ( String elementName , Map < String , String > attributes , StaticXmlMetawidget metawidget ) { StaticXmlWidget dataTable = super . createDataTableComponent ( elementName , attributes , metawidget ) ; dataTable . putAttribute ( "styleClass" , "data-table" ) ; StandardBindingProcessor bindingProcessor = metawidget . getWidgetProcessor ( StandardBindingProcessor . class ) ; if ( bindingProcessor != null ) { bindingProcessor . processWidget ( dataTable , elementName , attributes , ( StaticUIMetawidget ) metawidget ) ; } ReadableIdProcessor readableIdProcessor = metawidget . getWidgetProcessor ( ReadableIdProcessor . class ) ; if ( readableIdProcessor != null ) { readableIdProcessor . processWidget ( dataTable , elementName , attributes , metawidget ) ; } ValueHolder valueHolderTable = ( ValueHolder ) dataTable ; String tableValueExpression = valueHolderTable . getValue ( ) ; Class < ? > clazz = WidgetBuilderUtils . getActualClassOrType ( attributes , null ) ; if ( ! List . class . isAssignableFrom ( clazz ) ) { String asListValueExpression = "forgeview:asList(" + StaticFacesUtils . unwrapExpression ( tableValueExpression ) + ")" ; valueHolderTable . setValue ( StaticFacesUtils . wrapExpression ( asListValueExpression ) ) ; ( ( BaseStaticXmlWidget ) dataTable ) . putAdditionalNamespaceURI ( "forgeview" , "http://jboss.org/forge/view" ) ; } if ( ! TRUE . equals ( attributes . get ( N_TO_MANY ) ) || metawidget . isReadOnly ( ) ) { return dataTable ; } String componentType = WidgetBuilderUtils . getComponentType ( attributes ) ; if ( componentType == null ) { return dataTable ; } HtmlPanelGroup panelGroup = new HtmlPanelGroup ( ) ; FaceletsParam param = new FaceletsParam ( ) ; param . putAttribute ( "name" , COLLECTION_VAR ) ; param . putAttribute ( "value" , tableValueExpression ) ; panelGroup . getChildren ( ) . add ( param ) ; if ( ! List . class . isAssignableFrom ( clazz ) ) { valueHolderTable . setValue ( StaticFacesUtils . wrapExpression ( "forgeview:asList(" + COLLECTION_VAR + ")" ) ) ; } else { valueHolderTable . setValue ( StaticFacesUtils . wrapExpression ( COLLECTION_VAR ) ) ; } panelGroup . getChildren ( ) . add ( dataTable ) ; if ( ! attributes . containsKey ( INVERSE_RELATIONSHIP ) ) { HtmlPanelGrid panelGrid = new HtmlPanelGrid ( ) ; panelGrid . putAttribute ( "styleClass" , "data-table-footer" ) ; panelGrid . putAttribute ( "columns" , "2" ) ; panelGrid . putAttribute ( "columnClasses" , ",remove-column" ) ; HtmlSelectOneMenu select = new HtmlSelectOneMenu ( ) ; String selectId = dataTable . getAttribute ( "id" ) + "Select" ; select . putAttribute ( "id" , selectId ) ; String requestScopedValue = "requestScope['" + selectId + "']" ; select . setValue ( StaticFacesUtils . wrapExpression ( requestScopedValue ) ) ; String simpleComponentType = ClassUtils . getSimpleName ( componentType ) ; String controllerName = StringUtils . decapitalize ( simpleComponentType ) ; select . setConverter ( StaticFacesUtils . wrapExpression ( controllerName + "Bean.converter" ) ) ; addSelectItems ( select , StaticFacesUtils . wrapExpression ( controllerName + "Bean.all" ) , attributes ) ; panelGrid . getChildren ( ) . add ( select ) ; HtmlCommandLink addLink = new HtmlCommandLink ( ) ; addLink . putAttribute ( "styleClass" , "add-button" ) ; String addExpression = COLLECTION_VAR + ".add(" + requestScopedValue + ")" ; addLink . putAttribute ( "action" , StaticFacesUtils . wrapExpression ( addExpression ) ) ; addLink . putAttribute ( "onclick" , "if (document.getElementById(document.forms[0].id+':" + selectId + "').selectedIndex &lt; 1) { alert('Must select a " + StringUtils . uncamelCase ( simpleComponentType ) + "'); return false; }" ) ; addLink . putAttribute ( "id" , dataTable . getAttribute ( "id" ) + "Add" ) ; panelGrid . getChildren ( ) . add ( addLink ) ; panelGroup . getChildren ( ) . add ( panelGrid ) ; } return panelGroup ; }
Overridden to add row creation/deletion.