Example #1
0
  protected void _appendValueAttributeToResponse(WOResponse woresponse, WOContext wocontext) {
    WOComponent component = wocontext.component();

    Object valueInComponent = _value.valueInComponent(component);
    if (valueInComponent != null) {
      String stringValue = valueInComponent.toString();
      woresponse._appendTagAttributeAndValue("value", stringValue, true);
    }

    if (_size != null) {
      Object sizeInComponent = _size.valueInComponent(component);
      if (sizeInComponent != null) {
        String stringValue = sizeInComponent.toString();
        woresponse._appendTagAttributeAndValue("size", stringValue, true);
      }
    }

    if (_maxlength != null) {
      Object maxlengthInComponent = _maxlength.valueInComponent(component);
      if (maxlengthInComponent != null) {
        String stringValue = maxlengthInComponent.toString();
        woresponse._appendTagAttributeAndValue("maxlength", stringValue, true);
      }
    }

    if (_placeholder != null) {
      Object placeholderInComponent = _placeholder.valueInComponent(component);
      if (placeholderInComponent != null) {
        String stringValue = placeholderInComponent.toString();
        woresponse._appendTagAttributeAndValue("placeholder", stringValue, true);
      }
    }

    if (_pattern != null) {
      Object patternInComponent = _pattern.valueInComponent(component);
      if (patternInComponent != null) {
        String stringValue = patternInComponent.toString();
        woresponse._appendTagAttributeAndValue("pattern", stringValue, true);
      }
    } else {
      woresponse._appendTagAttributeAndValue("pattern", EMAIL_PATTERN, true);
    }

    if (isRequiredInContext(wocontext)) {
      woresponse._appendTagAttributeAndValue("required", "required", false);
    }

    if (isReadonlyInContext(wocontext)) {
      woresponse._appendTagAttributeAndValue("readonly", "readonly", false);
    }
  }
Example #2
0
 public void appendAttributesToResponse(WOResponse response, WOContext context) {
   WOComponent component = context.component();
   String href;
   if (_href != null) {
     href = (String) _href.valueInComponent(component);
   } else {
     String framework = "app";
     if (_framework != null) {
       Object val = _framework.valueInComponent(component);
       if (val != null) {
         framework = val.toString();
       }
     }
     String filename = (String) _filename.valueInComponent(component);
     WOResourceManager rs = WOApplication.application().resourceManager();
     href = rs.urlForResourceNamed(filename, framework, null, context.request());
   }
   response._appendTagAttributeAndValue("href", href, false);
   response._appendTagAttributeAndValue("rel", "SHORTCUT ICON", false);
   super.appendAttributesToResponse(response, context);
 }
Example #3
0
  /**
   * Looks through the child components to locate the AjaxTabbedPanelTabs that are controlled by
   * this panel. Tabs without an explicit id attributed are assigned a calculated one.
   *
   * @param template the graph of elements passed to the constructor.
   */
  private void findTabs(WODynamicGroup template) {
    if (template == null || template.childrenElements() == null) return;

    NSArray children = template.childrenElements();
    for (int i = 0; i < children.count(); i++) {
      WOElement child = (WOElement) children.objectAtIndex(i);
      if (child instanceof MTAjaxTabbedPanelTab) {
        MTAjaxTabbedPanelTab childTab = (MTAjaxTabbedPanelTab) child;

        // The tabs need to have an id attribute so we assign one if needed
        if (childTab.id() == null) {
          childTab.setId(
              new WOConstantValueAssociation(id.valueInComponent(null) + "_pane_" + tabs.count()));
        }

        tabs.addObject(childTab);
      } else if (child instanceof WODynamicGroup) {
        findTabs((WODynamicGroup) child);
      }
    }
  }
Example #4
0
  @Override
  public void appendToResponse(WOResponse response, WOContext context) {

    WOComponent component = context.component();
    String idString = (String) id.valueInComponent(component);
    if (idString == null) {
      throw new RuntimeException("id binding evaluated to null");
    }

    // UL for tabs
    response.appendContentString("<ul");
    appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
    appendTagAttributeToResponse(response, "id", idString);

    // Optional JavaScriplets
    if (onLoad != null) {
      appendTagAttributeToResponse(response, "onLoad", onLoad.valueInComponent(component));
    }
    if (onSelect != null) {
      appendTagAttributeToResponse(response, "onSelect", onSelect.valueInComponent(component));
    }

    response.appendContentString(">\n");

    String paneControlID = idString + "_panecontrol";
    String selectedTabClassName = stringValueForBinding("selectedPanelClassName", component);
    if (selectedTabClassName == null) {
      selectedTabClassName = "active";
    }
    for (MTAjaxTabbedPanelTab tab : tabs) {

      if (tab.isVisble(component)) {
        boolean isSelectedTab = tab.isSelected(context.component());
        String panelTabID = (String) tab.id().valueInComponent(component);
        String panelID = panelTabID + "_panel";
        response.appendContentString("  <li");
        if (isSelectedTab) {
          response.appendContentString(" class=\"");
          response.appendContentString(selectedTabClassName);
          response.appendContentString("\"");
        }
        response.appendContentString(">\n");
        response.appendContentString("<a ");

        // add the accesskey
        if (tab.accesskey() != null) {
          String accessKeyStr = tab.accesskey().valueInComponent(component).toString();
          appendTagAttributeToResponse(response, "accesskey", accessKeyStr);
        }

        appendTagAttributeToResponse(response, "href", "javascript:void(0)");
        appendTagAttributeToResponse(response, "rel", panelID);
        response.appendContentString("\">");
        response.appendContentString((String) tab.name().valueInComponent(component));
        response.appendContentString("</a>\n");
        response.appendContentString("</li>\n");
      }
    }

    response.appendContentString("</ul>\n");

    // UL for panes
    response.appendContentString("<ul class=\"ajaxTabbedPanelPanes\" ");
    appendTagAttributeToResponse(response, "id", paneControlID);
    response.appendContentString(">\n");
    // The tabs render themselves as panes
    if (content != null) {
      content.appendToResponse(response, context);
    }
    response.appendContentString("</ul>\n");
    super.appendToResponse(response, context);

    AjaxUtils.appendScriptHeader(response);
    response.appendContentString("window.addEvent('domready', function() {");
    response.appendContentString("\n\tvar ");
    response.appendContentString(safeID(context));
    response.appendContentString(" = new MTAjaxTabbedPanel({");
    response.appendContentString("tabbedPanelTabsContainer : ");
    response.appendContentString("'");
    response.appendContentString(idString);
    response.appendContentString("', ");
    response.appendContentString("tabbedPanelPanesContainer : ");
    response.appendContentString("'");
    response.appendContentString(paneControlID);
    response.appendContentString("'");
    if (!selectedTabClassName.equals("active")) {
      response.appendContentString(", ");
      response.appendContentString("selectedTabClassName : ");
      response.appendContentString("'");
      response.appendContentString(selectedTabClassName);
      response.appendContentString("'");
    }

    response.appendContentString("});");
    response.appendContentString("\n});");
    AjaxUtils.appendScriptFooter(response);
  }