Package org.richfaces.component

Examples of org.richfaces.component.UIComponentControl


            UIComponent component) throws IOException {
        if (!(component instanceof UIComponentControl)) {
            return;
        }
       
        UIComponentControl componentControl = (UIComponentControl) component;
        String attachTo = componentControl.getAttachTo();
        String attachTiming = componentControl.getAttachTiming();
        boolean isImmediate = attachTiming.equals(IMMEDIATE);
        boolean isOnLoad = attachTiming.equals(ON_LOAD);
        boolean isOnAvailable = attachTiming.equals(ON_AVAILABLE);
       
        if (!(isImmediate || isOnLoad || isOnAvailable || attachTo == null || attachTo.length() == 0)) {
            // unknown value of property "attachTiming"
            return;
        }
       
        ResponseWriter writer = context.getResponseWriter();
        ComponentVariables variables =
            ComponentsVariableResolver.getVariables(this, componentControl);
       
        writer.startElement("script", componentControl);
        getUtils().writeAttribute(writer, "type", "text/javascript");
        writer.writeText("//", null);
        writer.write("<![CDATA[");
       
        String attachEventBodyStart = "\n{\n    Richfaces.componentControl.attachEvent('";
        StringBuilder attachEventBodyEnd = new StringBuilder();
        attachEventBodyEnd.append("', '");
        attachEventBodyEnd.append(convertToString(variables.getVariable("event")));
        attachEventBodyEnd.append("', '");
        attachEventBodyEnd.append(convertToString(variables.getVariable("forAttr")));
        attachEventBodyEnd.append("', '");
        attachEventBodyEnd.append(convertToString(variables.getVariable("operation")));
        attachEventBodyEnd.append("', function() { return {");
        attachEventBodyEnd.append(convertToString(variables.getVariable("params")));
        attachEventBodyEnd.append("}; }, ");
        attachEventBodyEnd.append(convertToString(componentControl.isDisableDefault()));
        attachEventBodyEnd.append(");\n }");
       
        String pattern = "\\s*,\\s*";
        // "attachTo" attribute may contain several ids splitted by ","
        String[] result = attachTo.split(pattern);
View Full Code Here


    protected void attachEventAccordingToTimingOption(FacesContext context, UIComponent component) throws IOException {
  if (!(component instanceof UIComponentControl)) {
      return;
  }

  UIComponentControl componentControl = (UIComponentControl) component;
  String attachTo = componentControl.getAttachTo();
  String attachTiming = componentControl.getAttachTiming();
  boolean isImmediate = attachTiming.equals(IMMEDIATE);
  boolean isOnLoad = attachTiming.equals(ON_LOAD);
  boolean isOnAvailable = attachTiming.equals(ON_AVAILABLE);

  if (!(isImmediate || isOnLoad || isOnAvailable)) {
      // unknown value of property "attachTiming"
      return;
  }

  ResponseWriter writer = context.getResponseWriter();
  ComponentVariables variables = ComponentsVariableResolver.getVariables(this, componentControl);

  writer.startElement("script", componentControl);
  getUtils().writeAttribute(writer, "type", "text/javascript");
  writer.writeText("//", null);
  writer.write("<![CDATA[");

  String attachEventBodyStart = "\n{\n  Richfaces.componentControl.attachEvent('";
  StringBuilder attachEventBodyEnd = new StringBuilder();
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("event")));
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("forAttr")));
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("operation")));
  attachEventBodyEnd.append("', function() { return {");
  attachEventBodyEnd.append(convertToString(variables.getVariable("params")));
  attachEventBodyEnd.append("}; }, ");
  attachEventBodyEnd.append(convertToString(componentControl.isDisableDefault()));
  attachEventBodyEnd.append(");\n }");

  String pattern = "\\s*,\\s*";
  // "attachTo" attribute may contain several ids splitted by ","
  String[] result = attachTo.split(pattern);
View Full Code Here

    return ( obj == null ? "" : obj.toString() );
  }

  public void writeScript(FacesContext context, UIComponent component) throws IOException {

    UIComponentControl componentControl = (UIComponentControl) component;
    ResponseWriter writer = context.getResponseWriter();

    Map<String, Object> attributes = component.getAttributes();

    String name = convertToString(attributes.get("name"));
    String attachTo = convertToString(attributes.get("attachTo"));
    String forAttr = convertToString(attributes.get("for"));
    forAttr = replaceClientIds(context, component, forAttr);
    String operation = convertToString(attributes.get("operation"));
    String attachTiming = componentControl.getAttachTiming();
    checkValidity(componentControl.getClientId(context), name, attachTiming, forAttr, operation);
    String event = convertToString(attributes.get("event"));

    JSFunctionDefinition namedFunction = null;
    JSFunction eventFunction = null;

    if (name.trim().length() != 0) {
      JSFunction subFunction = new JSFunction("Richfaces.componentControl.performOperation");
      subFunction.addParameter(new JSReference("event"));
      componentControl.addOptions(subFunction, event, forAttr, operation);

      namedFunction = new JSFunctionDefinition("event");
      namedFunction.setName(name);
      namedFunction.addToBody(subFunction);
    }

    if (attachTo != null && attachTo.trim().length() != 0 && !"#".equals(attachTo)) {
      boolean isImmediate = attachTiming.equals(IMMEDIATE);
      boolean isOnLoad = attachTiming.equals(ON_LOAD);
      boolean isOnAvailable = attachTiming.equals(ON_AVAILABLE);

      if (isOnLoad) {
        eventFunction = new JSFunction("Richfaces.componentControl.attachReady");
      } else if (isOnAvailable) {
        eventFunction = new JSFunction("Richfaces.componentControl.attachAvailable");
      } else if (isImmediate) {
        eventFunction = new JSFunction("Richfaces.componentControl.attachEvent");
      } else {
        // unknown value of property "attachTiming"
        return;
      }

      // "attachTo" attribute may contain several ids splitted by ","
      String selector = replaceClientIds(context, component, attachTo);
      eventFunction.addParameter(selector);
      componentControl.addOptions(eventFunction, event, forAttr, operation);
    }

    if (eventFunction != null || namedFunction != null) {
      writer.startElement(HTML.SCRIPT_ELEM, componentControl);
      getUtils().writeAttribute(writer, HTML.TYPE_ATTR, "text/javascript");
View Full Code Here

    protected void attachEventAccordingToTimingOption(FacesContext context, UIComponent component) throws IOException {
  if (!(component instanceof UIComponentControl)) {
      return;
  }

  UIComponentControl componentControl = (UIComponentControl) component;
  String attachTo = componentControl.getAttachTo();
  String attachTiming = componentControl.getAttachTiming();
  boolean isImmediate = attachTiming.equals(IMMEDIATE);
  boolean isOnLoad = attachTiming.equals(ON_LOAD);
  boolean isOnAvailable = attachTiming.equals(ON_AVAILABLE);

  if (!(isImmediate || isOnLoad || isOnAvailable)) {
      // unknown value of property "attachTiming"
      return;
  }

  ResponseWriter writer = context.getResponseWriter();
  ComponentVariables variables = ComponentsVariableResolver.getVariables(this, componentControl);

  writer.startElement("script", componentControl);
  getUtils().writeAttribute(writer, "type", "text/javascript");
  writer.writeText("//", null);
  writer.write("<![CDATA[");

  String attachEventBodyStart = "\n{\n  Richfaces.componentControl.attachEvent('";
  StringBuilder attachEventBodyEnd = new StringBuilder();
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("event")));
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("forAttr")));
  attachEventBodyEnd.append("', '");
  attachEventBodyEnd.append(convertToString(variables.getVariable("operation")));
  attachEventBodyEnd.append("', function() { return {");
  attachEventBodyEnd.append(convertToString(variables.getVariable("params")));
  attachEventBodyEnd.append("}; }, ");
  attachEventBodyEnd.append(convertToString(componentControl.isDisableDefault()));
  attachEventBodyEnd.append(");\n }");

  String pattern = "\\s*,\\s*";
  // "attachTo" attribute may contain several ids splitted by ","
  String[] result = attachTo.split(pattern);
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIComponentControl

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.