Package javax.faces.component

Examples of javax.faces.component.UICommand


        UIComponent form = root.findComponent("testForm1");
        Assert.assertNotNull(form);
        UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UICommand button = (UICommand) compositeComponent.findComponent("button");
        Assert.assertNotNull(button);
        Assert.assertEquals("#{helloWorldBean.send}", button.getActionExpression().getExpressionString());
        Assert.assertEquals("#{helloWorldBean.send}", ((MethodExpression)compositeComponent.getAttributes().get("metodo")).getExpressionString());
        Assert.assertNull(button.getAttributes().get("metodo"));
       
        UICommand link = (UICommand) compositeComponent.findComponent("link");
        Assert.assertNotNull(link);
        Assert.assertEquals(1, link.getActionListeners().length);
        UIInput input = (UIInput) compositeComponent.findComponent("input");
        Assert.assertNotNull(input);
        Assert.assertEquals(1, input.getValidators().length);
        Assert.assertEquals(1, input.getValueChangeListeners().length);
       
View Full Code Here


       
        UIComponent form = root.findComponent("testForm1");
        Assert.assertNotNull(form);
        UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UICommand button = (UICommand) compositeComponent.findComponent("button");
        Assert.assertNotNull(button);
        Assert.assertEquals(3, button.getActionListeners().length);
       
        //StringWriter sw = new StringWriter();
        //MockResponseWriter mrw = new MockResponseWriter(sw);
        //facesContext.setResponseWriter(mrw);
       
View Full Code Here

        Assert.assertNotNull(form);
        UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button3");
        Assert.assertNotNull(compositeComponent2);
        UICommand button = (UICommand) compositeComponent2.findComponent("button");
        Assert.assertNotNull(button);
        //One added in testCompositeActionSource, the other one
        //inside compositeActionSource.xhtml
        Assert.assertEquals(2, button.getActionListeners().length);
       
        //StringWriter sw = new StringWriter();
        //MockResponseWriter mrw = new MockResponseWriter(sw);
        //facesContext.setResponseWriter(mrw);
       
View Full Code Here

        else
        {
            if (node.getChildCount() > 0)
            {
                // set up the expand control and remove whatever children (if any) this control had previously
                UICommand expandControl = tree.getExpandControl();
                expandControl.getChildren().clear();
                expandControl.setId(TOGGLE_ID);

                UIParameter param = new UIParameter();
                param.setName(tree.getId() + NamingContainer.SEPARATOR_CHAR + NAV_COMMAND);
                param.setValue(tree.getNodeId());
                expandControl.getChildren().add(param);
                expandControl.getChildren().add(image);

                RendererUtils.renderChild(context, expandControl);
            }
            else
            {
View Full Code Here

            encodeRecursive(context, image);
        }
        else
        {
            // set up the expand control and remove whatever children (if any) this control had previously
            UICommand expandControl = tree.getExpandControl();
            expandControl.setId(context.getViewRoot().createUniqueId());
            expandControl.getChildren().clear();

            UIParameter param = new UIParameter();
            param.setName(tree.getId() + NamingContainer.SEPARATOR_CHAR + NAV_COMMAND);
            param.setValue(tree.getNodeId());
            expandControl.getChildren().add(param);
            expandControl.getChildren().add(image);

            encodeRecursive(context, expandControl);
        }
        out.endElement(HTML.TD_ELEM);
View Full Code Here

            RendererUtils.renderChild(context, image);
        }
        else
        {
            // set up the expand control and remove whatever children (if any) this control had previously
            UICommand expandControl = tree.getExpandControl();
            expandControl.setId(context.getViewRoot().createUniqueId());
            expandControl.getChildren().clear();

            UIParameter param = new UIParameter();
            param.setName(tree.getId() + NamingContainer.SEPARATOR_CHAR + NAV_COMMAND);
            param.setValue(tree.getNodeId());
            expandControl.getChildren().add(param);
            expandControl.getChildren().add(image);

            RendererUtils.renderChild(context, expandControl);
        }
        out.endElement(HTML.TD_ELEM);
View Full Code Here

    {
      return;
    }

    Map<String, Object> attrs = component.getAttributes();
    UICommand command = (UICommand) component;
    // Which button type (SUBMIT, RESET, or BUTTON) should we generate?
    String type = CoreRenderer.toString(attrs.get("type"));
    if (type == null)
    {
      type = "submit";
    }

    ResponseWriter writer = context.getResponseWriter();

    String label = CoreRenderer.toString(command.getValue());

    String imageSrc = CoreRenderer.toResourceUri(context, attrs.get("image"));
    writer.startElement("input", component);
    String id = component.getClientId(context);
    writer.writeAttribute("id", id, "id");
    writer.writeAttribute("name", id, null);
    boolean isImage = (imageSrc != null);
    if (isImage)
    {
      imageSrc = context.getExternalContext().encodeResourceURL(imageSrc);
      writer.writeAttribute("type", "image", "type");
      writer.writeURIAttribute("src", imageSrc, "image");
    }
    else
    {
      writer.writeAttribute("type", type.toLowerCase(), "type");
      writer.writeAttribute("value", label, "value");
    }

    RenderingContext arc = RenderingContext.getCurrentInstance();
    String script;
    // If it's an image, we can't really go through the full-page submit
    // code - we need to preserve the x/y coordinates.  However,
    // we do need the "source" parameter to be set
    if (isImage)
    {
      script =  "this.form.source.value='" + id + "';";
      arc.getFormData().addNeededValue("source");
    }
    else
    {
      script = AutoSubmitUtils.getFullPageSubmitScript(
              arc, id, command.isImmediate(),
              null/*no event*/,
              null,
              false/* return false*/);
    }

View Full Code Here

      LOG.error("No actionListener found in tree, so tree editing will not work!");
    }

    UITreeOld.Command[] commands = getCommands();
    for (int i = 0; i < commands.length; i++) {
      UICommand command = (UICommand) ComponentUtil.createComponent(
          facesContext, UICommand.COMPONENT_TYPE,
          TobagoConstants.RENDERER_TYPE_LINK);
      toolbar.getChildren().add(command);
      command.setId(commands[i].getCommand());

      for (ActionListener listener : getActionListeners()) {
        command.addActionListener(listener);
      }
      command.setActionListener(getActionListener());
      command.getAttributes().put(
          TobagoConstants.ATTR_IMAGE, "image/tobago.tree." + commands[i].getCommand() + ".gif");
      String title = ResourceManagerUtil.getPropertyNotNull(facesContext, "tobago",
          "tree" + StringUtil.firstToUpperCase(commands[i].getCommand()));
      command.getAttributes().put(TobagoConstants.ATTR_TIP, title);

    }

    getFacets().put("defaultToolbar", toolbar);
View Full Code Here

      writer.writeClassAttribute("tobago-sheet-footer");
      writer.writeAttribute(HtmlAttributes.STYLE, footerStyle, null);


      if (isValidPagingValue(showRowRange)) {
        UICommand pagerCommand = (UICommand) data.getFacet(
            FACET_PAGER_ROW);
        if (pagerCommand == null) {
          pagerCommand = createPagingCommand(
                  application, PageAction.TO_ROW, false);
          data.getFacets().put(FACET_PAGER_ROW, pagerCommand);
        }
        String pagingOnClick
            = HtmlRendererUtil.createOnClick(facesContext, pagerCommand);
        pagingOnClick = pagingOnClick.replaceAll("'", "\"");
        final String pagerCommandId = pagerCommand.getClientId(facesContext);

        final String className = "tobago-sheet-paging-rows-span"
            + " tobago-sheet-paging-span-" + showRowRange;

        writer.startElement(HtmlConstants.SPAN, null);
        writer.writeAttribute(HtmlAttributes.ONCLICK, "tobagoSheetEditPagingRow(this, '"
            + pagerCommandId + "', '" + pagingOnClick + "')", null);
        writer.writeClassAttribute(className);
        writer.writeAttribute(HtmlAttributes.TITLE, ResourceManagerUtil.getPropertyNotNull(
            facesContext, "tobago", "sheetPagingInfoRowPagingTip"), null);
        writer.write(createSheetPagingInfo(data, facesContext,
            pagerCommandId, true));
        writer.endElement(HtmlConstants.SPAN);
      }


      if (isValidPagingValue(showDirectLinks)) {
        final String className = "tobago-sheet-paging-links-span"
            + " tobago-sheet-paging-span-" + showDirectLinks;

        writer.startElement(HtmlConstants.SPAN, null);
        writer.writeClassAttribute(className);
        writer.writeIdAttribute(sheetId + SUBCOMPONENT_SEP + "pagingLinks");
        writeDirectPagingLinks(writer, facesContext, application, data);
        writer.endElement(HtmlConstants.SPAN);
      }

      if (isValidPagingValue(showPageRange)) {
        UICommand pagerCommand
            = (UICommand) data.getFacet(FACET_PAGER_PAGE);
        if (pagerCommand == null) {
          pagerCommand = createPagingCommand(
              application, PageAction.TO_PAGE, false);
          data.getFacets().put(FACET_PAGER_PAGE, pagerCommand);
        }
        String pagingOnClick
            = HtmlRendererUtil.createOnClick(facesContext, pagerCommand);
        pagingOnClick = pagingOnClick.replaceAll("'", "\"");
        final String pagerCommandId = pagerCommand.getClientId(facesContext);

        final String className = "tobago-sheet-paging-pages-span"
            + " tobago-sheet-paging-span-" + showPageRange;

View Full Code Here

      LOG.debug("nodeId = '" + treeId + NamingContainer.SEPARATOR_CHAR
          + nodeId + "'");
    }
    if (actionId != null
        && actionId.equals(treeId + NamingContainer.SEPARATOR_CHAR + nodeId)) {
      UICommand treeNodeCommand
          = (UICommand) tree.getFacet(UITreeOld.FACET_TREE_NODE_COMMAND);
      if (treeNodeCommand != null) {
        UIParameter parameter = ensureTreeNodeParameter(treeNodeCommand);
        parameter.setValue(node.getId());
//        LOG.error("no longer supported: treeNodeCommand.fireActionEvent(facesContext));");
//        treeNodeCommand.fireActionEvent(facesContext); // FIXME jsfbeta
//        component.queueEvent(new ActionEvent(component));
        treeNodeCommand.queueEvent(new ActionEvent(treeNodeCommand));
      }

      UIForm form = ComponentUtil.findForm(component);
      if (form != null) {
        form.setSubmitted(true);
View Full Code Here

TOP

Related Classes of javax.faces.component.UICommand

Copyright © 2018 www.massapicom. 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.