Examples of HtmlCommandLink


Examples of org.metawidget.statically.faces.component.html.widgetbuilder.HtmlCommandLink

         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 < 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);
      }
View Full Code Here

Examples of org.metawidget.statically.faces.component.html.widgetbuilder.HtmlCommandLink

      if (!attributes.containsKey(N_TO_MANY) || metawidget.isReadOnly())
      {
         return;
      }

      HtmlCommandLink removeLink = new HtmlCommandLink();
      removeLink.putAttribute("styleClass", "remove-button");
      String removeExpression = COLLECTION_VAR + ".remove(" + dataTable.getAttribute("var") + ")";
      removeLink.putAttribute("action", StaticFacesUtils.wrapExpression(removeExpression));

      HtmlColumn column = new HtmlColumn();
      column.putAttribute("headerClass", "remove-column");
      column.putAttribute("footerClass", "remove-column");
      column.getChildren().add(removeLink);
      dataTable.getChildren().add(column);

      // If bidirectional, an 'Add' button too

      String inverseRelationship = attributes.get(INVERSE_RELATIONSHIP);

      if (inverseRelationship != null)
      {
         String componentType = WidgetBuilderUtils.getComponentType(attributes);

         if (componentType != null)
         {
            String controllerName = StringUtils.decapitalize(ClassUtils.getSimpleName(componentType));

            HtmlCommandLink addLink = new HtmlCommandLink();
            addLink.putAttribute("styleClass", "add-button");
            String addExpression = COLLECTION_VAR + ".add(" + controllerName + "Bean.added)";
            addLink.putAttribute("action", StaticFacesUtils.wrapExpression(addExpression));

            // Use a f:setPropertyActionListener to initialize the bidirectional relationship

            SetPropertyActionListener setPropertyActionListener = new SetPropertyActionListener();
            setPropertyActionListener.putAttribute(
                     "target",
                     StaticFacesUtils.wrapExpression(controllerName + "Bean.add." + inverseRelationship));
            StandardBindingProcessor bindingProcessor = metawidget.getWidgetProcessor(StandardBindingProcessor.class);

            if (bindingProcessor != null)
            {
               bindingProcessor.processWidget(setPropertyActionListener, ENTITY, attributes,
                        (StaticUIMetawidget) metawidget);
            }
            addLink.getChildren().add(setPropertyActionListener);

            // (id is useful for unit tests)

            String id = StaticFacesUtils.unwrapExpression(setPropertyActionListener.getValue())
                     + StringUtils.SEPARATOR_DOT_CHAR + attributes.get(NAME) + StringUtils.SEPARATOR_DOT_CHAR + "Add";

            addLink.putAttribute("id", StringUtils.camelCase(id, StringUtils.SEPARATOR_DOT_CHAR));

            Facet footerFacet = new Facet();
            footerFacet.putAttribute("name", "footer");
            footerFacet.getChildren().add(addLink);
            column.getChildren().add(footerFacet);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.