Examples of JSFunctionDefinition


Examples of org.ajax4jsf.javascript.JSFunctionDefinition

    if (functionName == null) {
      throw new FacesException("Value of 'name' attribute of a4j:jsFunction component is null!");
    }
   
    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.JSFunctionDefinition

        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);
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

           
      return parameters;
    }
   
    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");
      onPageChangeDef.addToBody(onPageChange);
      onPageChangeDef.addToBody("; return true;");

      definition.addToBody("if (");
      definition.addToBody(onPageChangeDef.toScript());
      definition.addToBody("(event)) {");
      definition.addToBody(buffer.toString());
      definition.addToBody("}");
  } else {
      definition.addToBody(buffer.toString());
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

    addEventHandler("onselectionchange");
    addOption("ids", ScrollableDataTableRendererState.getRendererState(context).getIds());
    addOption("hideWhenScrolling");
   
   
    JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
   
    JSReference sortEvent = new JSReference("event");
    functionDefinition.addParameter(sortEvent);
    functionDefinition.addToBody(onSortAjaxUpdate(context, grid));
   
    addOption("onSortAjaxUpdate", functionDefinition)
   
  }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

        if (null == implicitEventsQueue) {
            options.put("implicitEventsQueue", component.getClientId(context));
        }
        String onselect = (String) attributes.get("onselect");
        if (null != onselect) {
            JSFunctionDefinition function = new JSFunctionDefinition(
                    "suggestion");
            function.addParameter("event");
            function.addToBody(onselect);

            options.put("onselect", function);

        }
        String onobjectchange = (String) attributes.get("onobjectchange");
        if (null != onobjectchange) {
            JSFunctionDefinition function = new JSFunctionDefinition(
                    "suggestion","event");
            function.addToBody(onobjectchange);

            options.put("onobjectchange", function);

        }
        if (component.getValueBinding("fetchValue") != null
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

     * (non-Javadoc)
     *
     * @see org.richfaces.renderkit.html.TableMenuRenderer#createShowMenuEventFunction()
     */
    public JSFunctionDefinition createShowMenuEventFunction() {
        JSFunctionDefinition definition = new JSFunctionDefinition();
        definition.addParameter("event");
        definition.addParameter("columnId");
        definition.addParameter("menuId");
        JSFunction invocation = new JSFunction(
                "Richfaces.componentControl.performOperation");
        invocation.addParameter(new JSReference("event"));
        invocation.addParameter(new JSReference("menuId"));
        invocation.addParameter("show");
        // invocation.addParameter(new JSReference("{'columnId':columnId}"));
        invocation.addParameter(new JSReference("{}"));
        invocation.addParameter(Boolean.FALSE);
        definition.addToBody(invocation.toScript()).addToBody(";\n");
        return definition;
    }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

  public String getScriptContribution(FacesContext context, UIComponent column, String dropTargetScriptId, JSFunction preSendAjaxRequestFunction, JSFunctionDefinition onAjaxCompleteFunction) {
    StringBuffer result = new StringBuffer();

    result.append(".drop = ");

    JSFunctionDefinition definition = new JSFunctionDefinition();
    definition.addParameter("event");
    definition.addParameter("drag");

    Map<String, Object> requestOpts = AjaxRendererUtils.buildEventOptions(context, column);
    //replace parameters
    String clientId = column.getClientId(context);
    @SuppressWarnings("unchecked")
    Map<String, Object> parameters = (Map<String, Object>) requestOpts.get("parameters");
    if (parameters != null){
      if (parameters.containsKey(clientId)){
        parameters.remove(clientId);
        parameters.put(dropTargetScriptId, dropTargetScriptId);
      }
    }
   
    definition.addToBody("var dragParams = drag.getParameters();");
   
    String dragSourceScriptId = column.getClientId(context) + ":"+ TableDragDropRenderer.DRAG_SOURCE_SCRIPT_ID;
    definition.addToBody(
      "var source = dragParams['"+ DraggableRendererContributor.DRAG_SOURCE_ID +"'];" +
      "if (source != \"" + dragSourceScriptId + "\"){"//send request only if drag column in not equals to drop column
    );
    definition.addToBody("var options = ").addToBody(ScriptUtils.toScript(requestOpts)).addToBody(";");
    definition.addToBody("options.parameters['" + DropzoneRendererContributor.DROP_TARGET_ID + "'] = '" + dropTargetScriptId + "';");
    if (onAjaxCompleteFunction != null)   
      definition.addToBody("options['" + AjaxRendererUtils.ONCOMPLETE_ATTR_NAME + "'] = " + onAjaxCompleteFunction.toScript() + ";");
    //TODO remove as legacy
    definition.addToBody("Object.extend(options.parameters, dragParams);");
    if (preSendAjaxRequestFunction != null){
      definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
    }
    definition.addToBody("var dzOptions = this.getDropzoneOptions(); if (dzOptions.ondrop) { if (!dzOptions.ondrop.call(this, event)) return; };");
   
    JSFunction dropFunction = AjaxRendererUtils.buildAjaxFunction(column, context);
    dropFunction.addParameter(new JSReference("options"));
   
    definition.addToBody(dropFunction.toScript()).addToBody(";");
   
    definition.addToBody("};");
   
    definition.appendScript(result);
    result.append(";");

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

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

        // enable ajaxSingle mode, i.e. we do not need to submit all form
        // controls to get tooltip content
        eventOptions.put("control", JSReference.THIS);
       
        if (eventOptions.containsKey("oncomplete")) {
            JSFunctionDefinition onComplete =
                (JSFunctionDefinition) eventOptions.get("oncomplete");
            onComplete.addToBody(oncompleteTooltip);
            eventOptions.put("oncomplete", onComplete);
        } else {
            JSFunctionDefinition onComplete = new JSFunctionDefinition();
            onComplete.addParameter("request");
            onComplete.addParameter("showEvent");
            onComplete.addParameter("data");
            onComplete.addToBody(oncompleteTooltip);
            eventOptions.put("oncomplete", onComplete);
        }
       
        if (eventOptions.containsKey(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME)) {
            JSFunctionDefinition beforeUpdate = (JSFunctionDefinition) eventOptions
                    .get(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME);
            beforeUpdate.addToBody(fireBeforeUpdateDOM);
            eventOptions.put(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME, beforeUpdate);
        } else {
            JSFunctionDefinition beforeUpdate = new JSFunctionDefinition();
            beforeUpdate.addParameter("request");
            beforeUpdate.addParameter("showEvent");
            beforeUpdate.addParameter("data");
            beforeUpdate.addToBody(fireBeforeUpdateDOM);
            eventOptions.put(AjaxRendererUtils.ONBEFOREDOMUPDATE_ATTR_NAME, beforeUpdate);
        }
       
        return eventOptions;
    }
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

        eventsMap.put(new JSReference("hideEvent"), eventHide);

        eventsMap.put(new JSReference("delay"), new Integer(toolTip.getShowDelay()));
        eventsMap.put(new JSReference("hideDelay"), new Integer(toolTip.getHideDelay()));
       
        JSFunctionDefinition ajaxFunc = null;
        if (AJAX_MODE.equalsIgnoreCase(toolTip.getMode())) {
            ajaxFunc = new JSFunctionDefinition("event", "ajaxOptions");
            JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context);
            JSReference ref = new JSReference("ajaxOptions");
            function.addParameter(ref);
            ajaxFunc.addToBody(function);
        }
       
        Map<String, Object> ajaxOptions = buildEventOptions(context, toolTip, targetClientId);
        ajaxOptions.putAll(getParamsMap(context, toolTip));
       
        Map<JSReference, Object> funcMap = new HashMap<JSReference, Object>();
        JSFunctionDefinition completeFunc = getUtils().getAsEventHandler(
                context, component, "oncomplete", "; return true;");
        funcMap.put(new JSReference("oncomplete"), completeFunc);

        JSFunctionDefinition hideFunc = getUtils().getAsEventHandler(
                context, component, "onhide", "; return true;");
        funcMap.put(new JSReference("onhide"), hideFunc);

        JSFunctionDefinition showFunc = getUtils().getAsEventHandler(
                context, component, "onshow", "; return true;");
        funcMap.put(new JSReference("onshow"), showFunc);
       
        StringBuffer ret = new StringBuffer();
        ret.append("new ToolTip(").append(ScriptUtils.toScript(eventsMap)).append(COMMA)
View Full Code Here

Examples of org.ajax4jsf.javascript.JSFunctionDefinition

      FacesContext context) {
    Map options = AjaxRendererUtils.buildEventOptions(context, progressBar);
    Integer interval = new Integer(progressBar.getInterval());
    options.put("pollId", clientId);
    options.put("pollinterval", interval);
    JSFunctionDefinition onsubmit = getUtils().getAsEventHandler(context, progressBar, "onsubmit", "");
    if (onsubmit != null) {
      options.put("onsubmit", onsubmit);
    }
    if (progressBar.getAttributes().containsKey("ignoreDupResponses")) {
      options.put("ignoreDupResponses", progressBar.getAttributes().get(
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.