Пример #1
0
 private Tag trimNSAttributes(Tag tag) {
   TagAttribute[] attr = (TagAttribute[]) tag.getAttributes().getAll();
   int remove = 0;
   for (int i = 0; i < attr.length; i++) {
     if (attr[i].getQName().startsWith("xmlns")
         && this.tagLibrary.containsNamespace(attr[i].getValue(), null)) {
       remove |= 1 << i;
       if (log.isLoggable(Level.FINE)) {
         log.fine(attr[i] + " Namespace Bound to TagLibrary");
       }
     }
   }
   if (remove == 0) {
     return tag;
   } else {
     List attrList = new ArrayList(attr.length);
     int p = 0;
     for (int i = 0; i < attr.length; i++) {
       p = 1 << i;
       if ((p & remove) == p) {
         continue;
       }
       attrList.add(attr[i]);
     }
     attr = (TagAttribute[]) attrList.toArray(new TagAttribute[attrList.size()]);
     return new Tag(
         tag.getLocation(),
         tag.getNamespace(),
         tag.getLocalName(),
         tag.getQName(),
         new TagAttributesImpl(attr));
   }
 }
Пример #2
0
 private String[] determineQName(Tag tag) {
   TagAttribute attr = tag.getAttributes().get("jsfc");
   if (attr != null) {
     if (log.isLoggable(Level.FINE)) {
       log.fine(attr + " JSF Facelet Compile Directive Found");
     }
     String value = attr.getValue();
     String namespace, localName;
     int c = value.indexOf(':');
     if (c == -1) {
       namespace = this.namespaceManager.getNamespace("");
       localName = value;
     } else {
       String prefix = value.substring(0, c);
       namespace = this.namespaceManager.getNamespace(prefix);
       if (namespace == null) {
         throw new TagAttributeException(tag, attr, "No Namespace matched for: " + prefix);
       }
       localName = value.substring(c + 1);
     }
     return new String[] {namespace, localName};
   } else {
     return new String[] {tag.getNamespace(), tag.getLocalName()};
   }
 }
Пример #3
0
 /*
  * (non-Javadoc)
  *
  * @see com.sun.facelets.tag.TagDecorator#decorate(com.sun.facelets.tag.Tag)
  */
 @Override
 public Tag decorate(Tag tag) {
   if (XhtmlNamespace.equals(tag.getNamespace())) {
     String n = tag.getLocalName();
     if ("a".equals(n)) {
       return new Tag(
           tag.getLocation(),
           HtmlLibrary.Namespace,
           "commandLink",
           tag.getQName(),
           tag.getAttributes());
     }
     if ("form".equals(n)) {
       return new Tag(
           tag.getLocation(), HtmlLibrary.Namespace, "form", tag.getQName(), tag.getAttributes());
     }
     if ("input".equals(n)) {
       TagAttribute attr = tag.getAttributes().get("type");
       if (attr != null) {
         String t = attr.getValue();
         TagAttributes na = removeType(tag.getAttributes());
         if ("text".equals(t)) {
           return new Tag(
               tag.getLocation(), HtmlLibrary.Namespace, "inputText", tag.getQName(), na);
         }
         if ("password".equals(t)) {
           return new Tag(
               tag.getLocation(), HtmlLibrary.Namespace, "inputSecret", tag.getQName(), na);
         }
         if ("hidden".equals(t)) {
           return new Tag(
               tag.getLocation(), HtmlLibrary.Namespace, "inputHidden", tag.getQName(), na);
         }
         if ("submit".equals(t)) {
           return new Tag(
               tag.getLocation(), HtmlLibrary.Namespace, "commandButton", tag.getQName(), na);
         }
         if ("file".equals(t)) {
           return new Tag(
               tag.getLocation(), HtmlLibrary.Namespace, "inputFile", tag.getQName(), na);
         }
       }
     }
   }
   return null;
 }