Package com.ocpsoft.pretty.faces.component

Examples of com.ocpsoft.pretty.faces.component.Link


      if (!component.isRendered())
      {
         return;
      }

      Link link = (Link) component;
      ResponseWriter writer = context.getResponseWriter();

      if (link.isDisabled())
      {
         writer.startElement("span", link);
      }
      else
      {
         writer.startElement("a", link);
      }

      String mappingId = (String) component.getAttributes().get("mappingId");
      if (mappingId == null)
      {
         throw new PrettyException("Mapping id was null when attempting to build URL for component: "
                  + component.toString() + " <" + component.getClientId(context) + ">");
      }

      try
      {

         PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
         PrettyConfig prettyConfig = prettyContext.getConfig();
         UrlMapping urlMapping = prettyConfig.getMappingById(mappingId);

         String href = context.getExternalContext().getRequestContextPath()
               + urlBuilder.build(urlMapping, true, urlBuilder.extractParameters(component));

         if ((link.getAnchor() != null) && link.getAnchor().length() > 0)
         {
            href += "#" + link.getAnchor();
         }

         writer.writeURIAttribute("href", context.getExternalContext().encodeResourceURL(href), "href");

      }
      catch (PrettyException e)
      {
         throw new PrettyException("Failed to build URL for mapping '" + mappingId
               + "' while rendering <pretty:link> component: " + link.getClientId(context), e);
      }

      writeAttr(writer, "id", link.getClientId(context));
      writeAttr(writer, "accesskey", link.getAccesskey());
      writeAttr(writer, "charset", link.getCharset());
      writeAttr(writer, "coords", link.getCoords());
      writeAttr(writer, "dir", link.getDir());
      writeAttr(writer, "hreflang", link.getHreflang());
      writeAttr(writer, "lang", link.getLang());
      writeAttr(writer, "onblur", link.getOnblur());
      writeAttr(writer, "onclick", link.getOnclick());
      writeAttr(writer, "ondblclick", link.getOndblclick());
      writeAttr(writer, "onfocus", link.getOnfocus());
      writeAttr(writer, "onkeydown", link.getOnkeydown());
      writeAttr(writer, "onkeypress", link.getOnkeypress());
      writeAttr(writer, "onkeyup", link.getOnkeyup());
      writeAttr(writer, "onmousedown", link.getOnmousedown());
      writeAttr(writer, "onmousemove", link.getOnmousemove());
      writeAttr(writer, "onmouseout", link.getOnmouseout());
      writeAttr(writer, "onmouseover", link.getOnmouseover());
      writeAttr(writer, "onmouseup", link.getOnmouseup());
      writeAttr(writer, "rel", link.getRel());
      writeAttr(writer, "rev", link.getRev());
      writeAttr(writer, "shape", link.getShape());
      writeAttr(writer, "style", link.getStyle());
      writeAttr(writer, "class", link.getStyleClass());
      writeAttr(writer, "tabindex", link.getTabindex());
      writeAttr(writer, "target", link.getTarget());
      writeAttr(writer, "title", link.getTitle());
      writeAttr(writer, "type", link.getType());

   }
View Full Code Here


   }

   @Override
   public void encodeEnd(final FacesContext context, final UIComponent component) throws IOException
   {
      Link link = (Link) component;
      super.encodeEnd(context, link);

      if (!link.isRendered())
      {
         return;
      }

      ResponseWriter writer = context.getResponseWriter();

      if (link.isDisabled())
      {
         writer.endElement("span");
      }
      else
      {
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.faces.component.Link

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.