Package javax.faces.component

Examples of javax.faces.component.UICommand$MethodExpressionAdapter


            if (child instanceof ActionSource2 && child instanceof AbstractTogglePanelTitledItem && child instanceof UICommand) {
                String name = ((AbstractTogglePanelTitledItem) child).getName();
                // active item is determined by the name
                if (name.equals(activeItem)) {
                    // child needs to be UICommand to broadcast event
                    UICommand childCommand = (UICommand) child;
                    ActionEvent actionEvent = new ActionEvent(childCommand);
                    // if the immediate attribute is set than event should be broadcasted on the second phase APPLY_REQUEST_VALUES
                    // in other case it should be queued to be executed on
                    if(isImmediate()){
                        childCommand.broadcast(actionEvent);
                    } else {
                        actionEvent.queue();
                    }
                    break;
                }
View Full Code Here


        Facelet at = f.getFacelet("actionListener.xml");

        UIViewRoot root = faces.getViewRoot();
        at.apply(faces, root);

        UICommand action1 = (UICommand) root.findComponent("action1");
        UICommand action2 = (UICommand) root.findComponent("action2");

        assertNotNull("action1", action1);
        assertNotNull("action2", action2);

        assertEquals("action1 listeners", 1,
                action1.getActionListeners().length);
        assertEquals("action2 listeners", 2,
                action2.getActionListeners().length);

        assertEquals("action2 binding", listener,
                action2.getActionListeners()[0]);
    }
View Full Code Here

        }
        else
        {
            // 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);
        }
        out.endElement(HTML.TD_ELEM);
View Full Code Here

  protected String getTreeNodeCommandVar(FacesContext facesContext, UIComponent tree) {
    String clientId = tree.getClientId(facesContext);
    String jsClientId = TreeOldRenderer.createJavascriptVariable(clientId);

    String treeNodeCommandVar = "  var " + jsClientId + "_treeNodeCommand = ";
    UICommand treeNodeCommand = (UICommand) tree.getFacet(UITreeOld.FACET_TREE_NODE_COMMAND);
    if (treeNodeCommand != null) {
      CommandRendererHelper helper = new CommandRendererHelper(facesContext,
          treeNodeCommand);
      if (helper.getOnclick() != null) {
        String onclick = helper.getOnclick();
        String treeNodeCommandClientId = treeNodeCommand.getClientId(facesContext);
        onclick = onclick.replaceAll("'" + treeNodeCommandClientId + "'", "this.id");
        treeNodeCommandVar += "\"" + onclick + "\";\n";
      } else {
        treeNodeCommandVar += "null;\n";
      }
View Full Code Here

    if (!(component instanceof UICommand)) {
      LOG.error("Wrong type: Need " + UICommand.class.getName() + ", but was " + component.getClass().getName());
      return;
    }
   
    UICommand command = (UICommand) component;
    String clientId = command.getClientId(facesContext);
    String buttonType = createButtonType(command);

    CommandRendererHelper helper = new CommandRendererHelper(facesContext, command, CommandRendererHelper.Tag.BUTTON);

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);

    LabelWithAccessKey label = new LabelWithAccessKey(command);

    writer.startElement(HtmlConstants.BUTTON, command);
    writer.writeAttribute(HtmlAttributes.TYPE, buttonType, false);
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(clientId);
    writer.writeAttributeFromComponent(HtmlAttributes.TITLE, ATTR_TIP);
    writer.writeAttribute(HtmlAttributes.DISABLED, helper.isDisabled());
    Integer tabIndex = null;
    if (command instanceof UIButtonCommand) {
      tabIndex = ((UIButtonCommand) command).getTabIndex();
    }
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    if (helper.getOnclick() != null) {
      writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);
    }
    writer.writeStyleAttribute();
    writer.writeClassAttribute();
    writer.flush(); // force closing the start tag

//  image
    String imageName = (String) command.getAttributes().get(ATTR_IMAGE);
    if (imageName != null) {
      String image = null;
      if (imageName.startsWith("HTTP:") || imageName.startsWith("FTP:")
                || imageName.startsWith("/")) {
        image = imageName;
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.toUri(attrs.get("image"));
    writer.startElement("input", component);
    String id = component.getClientId(context);
    writer.writeAttribute("id", id, "id");
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("#{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

//      tobagoTag.setRendered("true");
      //tobagoTag.setDisabled("#{peter.male}");
      //tobagoTag.setHeight("#{marry.size}");
      tobagoTag.doStartTag();
      UIComponent component = tobagoTag.getComponentInstance();
      UICommand command = (UICommand) component;
      Object disabled = component.getAttributes().get(Attributes.DISABLED);
      LOG.debug("disabled = '" + disabled + "'");
      Map attributes = component.getAttributes();
      for (Iterator i = attributes.keySet().iterator(); i.hasNext();) {
        Object value = i.next();
View Full Code Here

TOP

Related Classes of javax.faces.component.UICommand$MethodExpressionAdapter

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.