Examples of JSFunction


Examples of org.ajax4jsf.javascript.JSFunction

      if (commandOnEvent != null) {
        onEvent.append(commandOnEvent);
        onEvent.append(';');
      }
    }
    JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
    // Create formal parameter for non-input elements ???
    // Link Control pseudo-object
    // Options map. Possible options for function call :
    // control - name of form control for submit.
    // name - name for link control \
    // value - value of control. - possible replace by parameters ?
    // single true/false - submit all form or only one control.
    // affected - array of element's ID for update on responce.
    // oncomplete - function for call after complete request.
    // status - id of request status component.
    // parameters - map of parameters name/value for append on request.
    // TODO
    // sync true/false - run script in sync mode.
    // ..........
    ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));

    // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
    ajaxFunction.appendScript(onEvent);
    if (uiComponent instanceof AjaxSupport) {
      AjaxSupport support = (AjaxSupport) uiComponent;
      if (support.isDisableDefault()) {
        onEvent.append("; return false;");
      }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

   *            TODO
   * @return
   */
  public static JSFunction buildAjaxFunction(UIComponent uiComponent,
      FacesContext facesContext) {
    JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
        AJAX_FUNCTION_NAME);
    // client-side script must have reference to event-enabled object.
    ajaxFunction.addParameter(new JSReference("event"));
    return ajaxFunction;
  }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

   *            TODO
   * @return
   */
  public static JSFunction buildAjaxFunction(UIComponent uiComponent,
      FacesContext facesContext, String functionName) {
    JSFunction ajaxFunction = new JSFunction(functionName);
    UIComponent nestingContainer = (UIComponent) findAjaxContainer(
        facesContext, uiComponent);
   
   
    String clientId = nestingContainer.getClientId(facesContext);
    if (clientId != null) {
        ajaxFunction.addParameter(clientId);
    } else {
        // fix for myfaces 1.2.4
        ajaxFunction.addParameter(JSReference.NULL);  
    }
       
    // build form name or ActionUrl for script
    UIComponent nestingForm = getNestingForm(uiComponent);
    if (null == nestingForm) {
      ajaxFunction.addParameter(JSReference.NULL);
    } else {
      ajaxFunction.addParameter(nestingForm.getClientId(facesContext));
    }
    return ajaxFunction;
  }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

      // pushing script.
        writer.startElement(HTML.SCRIPT_ELEM, component);
        writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
        StringBuffer script = new StringBuffer("\n");
        if(push.isEnabled()){
        JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context, AJAX_PUSH_FUNCTION);
        // Set dummy form id, if nessesary.
        Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, component);
        options.put("dummyForm", component.getClientId(context)+RendererUtils.DUMMY_FORM_ID);
        int interval = push.getInterval();
        if(interval == Integer.MIN_VALUE){
            String intervalInitParameter = context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
            if(null != intervalInitParameter){
          interval = Integer.parseInt(intervalInitParameter);
            } else {
          interval = DEFAULT_PUSH_INTERVAL;
            }
        }
        options.put("pushinterval", new Integer(interval));
        options.put("pushId", push.getListenerId(context));
        String pushUrl = context.getExternalContext().getInitParameter(PUSH_URL_PARAMETER);
        if(null != pushUrl){
            options.put("pushUrl", pushUrl);
        }
        //        options.put("timeout", interval);
        function.addParameter(options);
        function.appendScript(script);
        } else {
          script.append("A4J.AJAX.StopPush('").append(push.getListenerId(context)).append("')");
        }
        script.append(";\n");
        writer.writeText(script.toString(),null);
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

   
    StringBuffer script = new StringBuffer(functionName).append("=");
    JSFunctionDefinition func = new JSFunctionDefinition();
    //func.setName(component.getName());
    // Create AJAX Submit function.
    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
        component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
    Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, component);
    Map<String, Object> parameters = (Map<String, Object>) options.get("parameters");
    if (null == parameters) {
      parameters = new HashMap<String, Object>();
      options.put("parameters", parameters);
    }
    ajaxFunction.addParameter(JSReference.NULL);
    ajaxFunction.addParameter(options);
    // Fill parameters.
    for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
      UIComponent child = it.next();
      if (child instanceof UIParameter) {
        UIParameter parameter = ((UIParameter) child);
        String name = parameter.getName();
        func.addParameter(name);
        // Put parameter name to AJAX.Submit parameter, with default value.
        JSReference reference = new JSReference(name);
        if (null != parameter.getValue()) {
          reference = new JSReference(name + "||"
              + ScriptUtils.toScript(parameters.get(name)));

        }
        // Replace parameter value to reference.
        parameters.put(name, reference);
      }
    }
    func.addToBody(ajaxFunction.toScript());
    func.appendScript(script);
    return script.toString();
  }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

      // polling script.
        writer.startElement(HTML.SCRIPT_ELEM, component);
        writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
        StringBuffer script = new StringBuffer("\n");
        if(poll.isEnabled()){
        JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context, AJAX_POLL_FUNCTION);
        Map options = AjaxRendererUtils.buildEventOptions(context, component);
        Integer interval = new Integer(poll.getInterval());
        options.put("pollinterval", interval);
        options.put("pollId", component.getClientId(context));
        Object onsubmit = component.getAttributes().get("onsubmit");
        if (null != onsubmit) {
          JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
          onsubmitFunction.addToBody(onsubmit);
          options.put("onsubmit", onsubmitFunction);
        }

//        options.put("timeout", interval);
        function.addParameter(options);
        function.appendScript(script);
        } else {
          script.append("A4J.AJAX.StopPoll('").append(component.getClientId(context)).append("')");
        }
        script.append(";\n");
        writer.writeText(script.toString(),null);
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

        FORM_HAS_COMMAND_LINK_ATTR, clientId);
    if (component instanceof UIAjaxForm) {
      UIAjaxForm form = (UIAjaxForm) component;
      if (form.isAjaxSubmit()) {
        StringBuffer onSubmit = new StringBuffer("javascript:");
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
            component, context,
            AJAX_FORM_FUNCTION_NAME);
        ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
            context, component));
        ajaxFunction.appendScript(onSubmit);
        writer.writeURIAttribute("action", onSubmit, "action");
      } else {
        encodeSubmitAction(writer, context);
      }
    } else {
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

  }

  @Override
  protected String getLayerScript(FacesContext context, UIComponent component) {
    StringBuffer buffer = new StringBuffer();
    JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
    function.addParameter(component.getClientId(context)+"_menu");
    function.addParameter(component.getAttributes().get("showDelay"));
       
    if (component instanceof UIDropDownMenu) {
        function.addParameter(component.getAttributes().get("hideDelay"));
        Object selectedClass = component.getAttributes().get("selectedLabelClass");
        if (null != selectedClass && !"".equals(selectedClass)) {
          function.addParameter(selectedClass);
        }
        } else {
          function.addParameter(new Integer(300));
        }
       
    function.appendScript(buffer);
   
    if (component instanceof UIMenuGroup) {
        buffer.append(".");
        function = new JSFunction("asSubMenu");
        function.addParameter(component.getParent().getClientId(context)+"_menu");
        function.addParameter(component.getClientId(context));
         String evt = (String) component.getAttributes().get("event");
        if(evt == null || evt.trim().length() == 0){
          evt = "onmouseover";
        }
        function.addParameter(evt);
        ScriptOptions subMenuOptions = new ScriptOptions(component);
        subMenuOptions.addEventHandler("onopen");
        subMenuOptions.addEventHandler("onclose");
        subMenuOptions.addOption("direction");
        subMenuOptions.addOption("highlightParent", Boolean.TRUE);
        function.addParameter(subMenuOptions);
        function.appendScript(buffer);

    } else {
        buffer.append(".");
        function = new JSFunction("asDropDown");
        function.addParameter(component.getClientId(context));
        function.addParameter(component.getClientId(context) + "_span");
          String evt = (String) component.getAttributes().get("event");
        if(evt == null || evt.trim().length() == 0){
          evt = "onmouseover";
        }
        function.addParameter(evt);
        function.addParameter("onmouseout");
        ScriptOptions menuOptions = new ScriptOptions(component);

        menuOptions.addOption("direction");
        menuOptions.addOption("jointPoint");
        menuOptions.addOption("verticalOffset");


        menuOptions.addOption("horizontalOffset");
        menuOptions.addEventHandler("oncollapse");
        menuOptions.addEventHandler("onexpand");
        menuOptions.addEventHandler("onitemselect");
        menuOptions.addEventHandler("ongroupactivate");
        menuOptions.addOption("disabled");
        function.addParameter(menuOptions);
        function.appendScript(buffer);

    }
   
    return buffer.toString();
  }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

    }
   
    public String getSubmitFunction(FacesContext context, UIComponent component) {
  JSFunctionDefinition definition = new JSFunctionDefinition("event");
       
  JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
                context);
        Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
                component);
        Map parameters = (Map) eventOptions.get("parameters");
       
        Map params = getParameters(context,component);
        if(!params.isEmpty()){
          parameters.putAll(params);
        }
       
        parameters.put(component.getClientId(context), new JSLiteral("event.memo.page"));
       
        function.addParameter(eventOptions);
        StringBuffer buffer = new StringBuffer();
        function.appendScript(buffer);
        buffer.append("; return false;");

  String onPageChange = (String) component.getAttributes().get("onpagechange");
  if (onPageChange != null && onPageChange.length() != 0) {
      JSFunctionDefinition onPageChangeDef = new JSFunctionDefinition("event");
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunction

    parametersMap.put(id + ":sortOrder", sortOrder);
    parametersMap.put(id + ":sortStartRow", sortStartRow);
    parametersMap.put(id + ":sortIndex", sortIndex);
    options.put("parameters", parametersMap);
   
    JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
    options.put("oncomplete", AjaxFunctionBuilder.getOnComplete(context, grid, AjaxFunctionBuilder.SORT));
    function.addParameter(options);
    String completeFunction = function.toScript() + "; return false;";
   
    return completeFunction;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.