Package javax.faces.component

Examples of javax.faces.component.UIGraphic


    attributes.put(ATTR_ACTION_ONCLICK, "Tobago.closePickerPopup('" + popup.getClientId(facesContext) + "')");
    cancelButton.setId(DatePickerController.CLOSE_POPUP);
    cancelButton.setActionListener(datePickerController);

    // create image
    UIGraphic image = (UIGraphic) ComponentUtil.createComponent(
        facesContext, UIGraphic.COMPONENT_TYPE, RENDERER_TYPE_IMAGE);
    image.setRendered(true);
    image.setValue("image/date.gif");
    image.getAttributes().put(ATTR_ALT, ""); //TODO: i18n
    image.getAttributes().put(ATTR_STYLE_CLASS, "tobago-input-picker");
    image.setId(idPrefix + "image");

    // add image
    link.getChildren().add(image);

    return link;
View Full Code Here


  /**
   * @deprecated since 2.0.0
   */
  @Deprecated
  public static UIGraphic getFirstGraphicChild(final UIComponent component) {
    UIGraphic graphic = null;
    for (final UIComponent child : component.getChildren()) {
      if (child instanceof UIGraphic) {
        graphic = (UIGraphic) child;
        break;
      }
View Full Code Here

        comp1.setId("comp1");

        comp2 = new UIOutput();
        comp2.setId("comp2");

        comp3 = new UIGraphic();
        comp3.setId("comp3");

        facet1 = new UIOutput();
        facet1.setId("comp4");

        facet2 = new UIOutput();
        facet2.setId("comp2");

        comp2.getFacets().put("facet1", facet1);
        comp2.getFacets().put("facet2", facet2);

        root.getChildren().add(comp1);
        root.getChildren().add(comp2);
        root.getChildren().add(comp3);

        HttpSession session =
            (HttpSession) context.getExternalContext().getSession(false);
        session.setAttribute("/test", root);


        context.setViewRoot(root);

        StateManagerImpl stateManager = (StateManagerImpl) context.getApplication()
            .getStateManager();

        boolean exceptionThrown = false;
        try {
            stateManager.saveSerializedView(context);
        } catch (IllegalStateException ise) {
            exceptionThrown = true;
        }
        assertTrue(exceptionThrown);
       
       
        // multiple componentns with a null ID should not
        // trigger an exception
        // construct a view
        root = Util.getViewHandler(getFacesContext()).createView(context, null);
        root.setViewId("/test");
        root.setId("root");
        root.setLocale(Locale.US);

        comp1 = new UIInput();
        comp1.setId("comp1");

        comp2 = new UIOutput();
        comp2.setId(null);

        comp3 = new UIGraphic();
        comp3.setId(null);

        facet1 = new UIOutput();
        facet1.setId("comp4");

        facet2 = new UIOutput();
        facet2.setId("comp2");

        comp2.getFacets().put("facet1", facet1);
        comp2.getFacets().put("facet2", facet2);

        root.getChildren().add(comp1);
        root.getChildren().add(comp2);
        root.getChildren().add(comp3);

        session.setAttribute("/test", root);

        context.setViewRoot(root);

        exceptionThrown = false;
        try {
            stateManager.saveSerializedView(context);
        } catch (IllegalStateException ise) {
            exceptionThrown = true;
        }
        assertTrue(!exceptionThrown);
       
        // transient components with duplicate ids should
        // trigger an error condition
        // construct a view
        root = Util.getViewHandler(getFacesContext()).createView(context, null);
        root.setViewId("/test");
        root.setId("root");
        root.setLocale(Locale.US);

        comp1 = new UIInput();
        comp1.setId("comp1");
        comp1.setTransient(true);

        comp2 = new UIOutput();
        comp2.setId("comp1");
        comp2.setTransient(true);

        comp3 = new UIGraphic();
        comp3.setId("comp3");

        facet1 = new UIOutput();
        facet1.setId("comp4");
View Full Code Here

        comp1.setId("comp1");

        comp2 = new UIOutput();
        comp2.setId("comp2");

        comp3 = new UIGraphic();
        comp3.setId("comp3");

        facet1 = new UIOutput();
        facet1.setId("comp4");
View Full Code Here

  private List<String> getImages(FacesContext facesContext, ImageSwitch imageSwitch) {
    List<String> images = new ArrayList<String>();
   
    for(UIComponent child : imageSwitch.getChildren()) {
      if(child instanceof UIGraphic) {
        UIGraphic image = (UIGraphic) child;
       
        if(image.isRendered())
          images.add(getResourceURL(facesContext, image.getUrl()));
      }
    }
   
    return images;
  }
View Full Code Here

        linkRenderer.encodeEnd(getFacesContext(), uiOutput);
        getFacesContext().getResponseWriter().writeText("\n", null);

        // Test link as image
        uiOutput = new UIOutput();
        UIGraphic graphic = new UIGraphic();
        uiOutput.setId("linkImage");
        uiOutput.setValue("hrefValue");
        graphic.setValue("duke.gif");
        uiOutput.getChildren().add(graphic);
        root.getChildren().add(uiOutput);
        System.out.println("Testing link as image");
        linkRenderer.encodeBegin(getFacesContext(), uiOutput);
        linkRenderer.encodeChildren(getFacesContext(), uiOutput);
        linkRenderer.encodeEnd(getFacesContext(), uiOutput);
        getFacesContext().getResponseWriter().writeText("\n", null);

        // Test link as image with image specified in resource bundle
        uiOutput = new UIOutput();
        graphic = new UIGraphic();
        uiOutput.setId("linkImage2");
        uiOutput.setValue("hrefValue");
        vb = ELUtils.createValueExpression("#{Messages.imagekey}");
        graphic.setValueExpression("value", vb);
        uiOutput.getChildren().add(graphic);
        root.getChildren().add(uiOutput);
        System.out.println("Testing link image via resource lookup");
        linkRenderer.encodeBegin(getFacesContext(), uiOutput);
        linkRenderer.encodeChildren(getFacesContext(), uiOutput);
View Full Code Here

        linkRenderer.encodeEnd(getFacesContext(), uiCommand);
        getFacesContext().getResponseWriter().writeText("\n", null);

        // Test link as image
        uiCommand = new UICommand();
        UIGraphic graphic = new UIGraphic();
        uiCommand.setId("linkImage");
        graphic.setValue("duke.gif");
        uiCommand.getChildren().add(graphic);
        form.getChildren().add(uiCommand);
        System.out.println("Testing link as image");
        linkRenderer.encodeBegin(getFacesContext(), uiCommand);
        linkRenderer.encodeChildren(getFacesContext(), uiCommand);
        linkRenderer.encodeEnd(getFacesContext(), uiCommand);
        getFacesContext().getResponseWriter().writeText("\n", null);

        // Test link as image with image specified in resource bundle
        uiCommand = new UICommand();
        graphic = new UIGraphic();
        uiCommand.setId("linkImage2");
        vb = ELUtils.createValueExpression("#{Messages.imagekey}");
        graphic.setValueExpression("value", vb);
        uiCommand.getChildren().add(graphic);
        form.getChildren().add(uiCommand);
        System.out.println("Testing link image via resource lookup");
        linkRenderer.encodeBegin(getFacesContext(), uiCommand);
        linkRenderer.encodeChildren(getFacesContext(), uiCommand);
View Full Code Here

    }


    public void testGraphicImageRenderer(UIComponent root) throws IOException {
        System.out.println("Testing GraphicImageRenderer");
        UIGraphic img = new UIGraphic();
        img.setUrl("/nonModelReferenceImage.gif");
        img.setId("myGraphicImage");
        img.getAttributes().put("ismap", new Boolean(true));
        img.getAttributes().put("usemap", "usemap");
        root.getChildren().add(img);

        ImageRenderer imageRenderer = new ImageRenderer();

        // test decode method

        System.out.println("    Testing decode method...");
        imageRenderer.decode(getFacesContext(), img);

        // test encode method

        System.out.println("    Testing encode method...");
        imageRenderer.encodeBegin(getFacesContext(), img);
        imageRenderer.encodeEnd(getFacesContext(), img);

        System.out.println("    Testing graphic support of modelReference...");
        root.getChildren().remove(img);
        img = new UIGraphic();
        img.getAttributes().put("ismap", new Boolean(true));
        img.getAttributes().put("usemap", "usemap");
        root.getChildren().add(img);
        com.sun.faces.cactus.TestBean testBean = (com.sun.faces.cactus.TestBean)
            (ELUtils.createValueExpression("#{TestBean}")).getValue(getFacesContext().getELContext());
        assertTrue(null != testBean); // set in FacesTestCaseService
        testBean.setImagePath("/foo/modelReferenceImage.gif");
        img.setValueExpression("value",
                            ELUtils.createValueExpression("#{TestBean.imagePath}"));

        imageRenderer.encodeBegin(getFacesContext(), img);
        imageRenderer.encodeEnd(getFacesContext(), img);
    }
View Full Code Here

      status2.setStartStyleClass("A B C D");
      status2.setStopStyle("color: green;");
      status2.setStopStyleClass("X Y Z");
      status2.getAttributes().put("layout", "inline");
     
      UIGraphic startImage = new UIGraphic();
      startImage.setValue("start.png");
      startImage.getAttributes().put("alt", "alt");
      status2.getFacets().put("start", startImage);
     
      UIGraphic stopGraphic = new UIGraphic();
      stopGraphic.setValue("stop.png");
      stopGraphic.getAttributes().put("alt", "alt");
      status2.getFacets().put("stop", stopGraphic);
     
      form.getChildren().add(status1);
      form.getChildren().add(status2);
  }
View Full Code Here

            //out.writeURIAttribute("background", getImageSrc(context, tree, "line-trunk.gif", true), null);
            out.writeURIAttribute(HTML.STYLE_ATTR, "background-image:url('" + getImageSrc(context, tree, "line-trunk.gif", true) + "');", null);
        }

//      add the appropriate image for the nav control
        UIGraphic image = new HtmlGraphicImage();
        String imageId = IMAGE_PREFIX+(counter++);
        image.setId(imageId);
        image.setUrl(navSrcUrl);
       
        Map imageAttrs = image.getAttributes();
        imageAttrs.put(HTML.WIDTH_ATTR, "19");
        imageAttrs.put(HTML.HEIGHT_ATTR, "18");
        imageAttrs.put(HTML.BORDER_ATTR, "0");
        imageAttrs.put(HTML.ALT_ATTR, "Nav control image"); // placing a suitable description for the alt.

        if (clientSideToggle)
        {
            /**
             * With client side toggle, user has the option to specify open/closed images for the node (in addition to
             * the navigtion ones provided by the component.)
             */
            String expandImgSrc = "";
            String collapseImgSrc = "";
            String nodeImageId = "";

            UIComponent expandFacet = nodeTypeFacet.getFacet("expand");
            if (expandFacet != null)
            {
                UIGraphic expandImg = (UIGraphic)expandFacet;
                expandImgSrc = context.getApplication().getViewHandler().getResourceURL(context, expandImg.getUrl());
                if (expandImg.isRendered())
                {
                    expandImg.setId(imageId + NODE_STATE_EXPANDED);
                    expandImg.setParent(tree);
                    nodeImageId = expandImg.getClientId(context);
                    nodeImgFacet = expandFacet;
                }
            }

            UIComponent collapseFacet = nodeTypeFacet.getFacet("collapse");
            if (collapseFacet != null)
            {
                UIGraphic collapseImg = (UIGraphic)collapseFacet;
                collapseImgSrc = context.getApplication().getViewHandler().getResourceURL(context, collapseImg.getUrl());
                if (collapseImg.isRendered())
                {
                    collapseImg.setId(imageId + NODE_STATE_CLOSED);
                    collapseImg.setParent(tree);
                    nodeImageId = collapseImg.getClientId(context);
                    nodeImgFacet = collapseFacet;
                }
            }

            image.setParent(tree);
View Full Code Here

TOP

Related Classes of javax.faces.component.UIGraphic

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.