boolean isNameSpace(Element element, String namespace) {
   if (element.getNamespace() == null) {
     return false;
   }
   if (element.getNamespace().equals(namespace)) {
     return true;
   }
   return false;
 }
示例#2
0
  void afterRender(MarkupWriter writer) {
    // If the Label element has a body that renders some non-blank output, that takes precendence
    // over the label string provided by the field.

    boolean bodyIsBlank = InternalUtils.isBlank(labelElement.getChildMarkup());

    if (bodyIsBlank) writer.write(field.getLabel());

    writer.end(); // label

    decorator.afterLabel(field);
  }
示例#3
0
 /**
  * Tapestry render phase method. End a tag here.
  *
  * @param writer the markup writer
  */
 void afterRender(MarkupWriter writer) {
   Element element = writer.getDocument().getElementById(clientElement.getClientId());
   javascriptSupport.addScript(
       "Nifty('%s#%s','%s');", element.getName(), clientElement.getClientId(), options);
 }
  @Override
  public void insideLabel(Field field, Element element) {
    if (field == null) return;

    if (inError(field)) element.addClassName(CSSClassConstants.ERROR);
  }
  @AfterRender
  public void afterRender(MarkupWriter writer) {
    String id;
    if (elementName == null) {
      elementName = resources.getElementName();
      if (elementName == null) {
        elementName = "ul";
      }
    }
    if (draggableName == null) {
      draggableName = "div";
      if (elementName.equals("ul")) {
        draggableName = "li";
      }
    }

    Object compoment = resources.getContainer();
    if (ClientElement.class.isAssignableFrom(compoment.getClass())) {
      id = ((ClientElement) compoment).getClientId();
    } else {
      id = javaScriptSupport.allocateClientId(resources);
    }
    if (Grid.class.isAssignableFrom(compoment.getClass())) {
      elementName = "tbody";
      draggableName = "tr";
    }

    element = writer.getElement();

    element.visit(
        new Visitor() {

          public void visit(Element e) {
            if (e.getName().equals(elementName)) {
              element = e;
            }
            if (e.getName().equals("tr")) {
              String c = e.getAttribute("class");
              if (c != null) {
                e.forceAttributes("id", c.split(" ")[0]);
              }
            }
          }
        });
    String currentID = element.getAttribute("id");
    if (currentID != null) {
      id = currentID;
    } else {
      element.forceAttributes("id", id);
    }
    // element.addClassName("sortable");
    // logger.info("spec {}",spec);
    if (!spec.has("selector")) {
      spec.put("selector", String.format("#%s %s", id, draggableName));
    }
    if (!spec.has("context")) {
      ArrayEventContext aec = new ArrayEventContext(typeCoercer, defaulted(context));
      spec.put("context", String.format("/%s", contextPathEncoder.encodeIntoPath(aec)));
    }
    javaScriptSupport.addInitializerCall("jqDraggable", spec);
  }