Package org.ajax4jsf.javascript

Examples of org.ajax4jsf.javascript.JSFunctionDefinition


    if (event != null) {
      event = event.trim();

      if (event.length() != 0) {
        JSFunctionDefinition function = new JSFunctionDefinition();
        function.addParameter("event");
        function.addToBody(event);

        result = function;
      }
    }
View Full Code Here


  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);
      }
    }
   
    if (preSendAjaxRequestFunction != null){
      definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
    }
    definition.addToBody("var options = ").addToBody(ScriptUtils.toScript(requestOpts)).addToBody(";");
    definition.addToBody("options.parameters['" + org.richfaces.renderkit.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,drag.getParameters());");
    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.appendScript(result);
    result.append(";");

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

        attribut = attributes.get("onselectionchange");
        if (attribut == null) {
            attribut = "";
        }
        JSFunctionDefinition function = new JSFunctionDefinition();
        function.addToBody(attribut);
        scriptOptions.addEventHandler("onselectionchange", function);
        return scriptOptions;
    }
View Full Code Here

    Iterator iterator = opts.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry entry = (Map.Entry) iterator.next();
      Object value = entry.getValue();
      if (value instanceof JSFunctionDefinition) {
        JSFunctionDefinition definition = (JSFunctionDefinition) value;
        entry.setValue(definition.toScript());
      }
    }
  }
View Full Code Here

        if (null == eventsQueue) {
            options.put("eventsQueue", 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

           
      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

      case SORT:        
        function = createFunction(ScrollableDataTableBaseRenderer.getJavaScriptVarName(context, grid) + ".onSortComplete");
        break;
   

    JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
    functionDefinition.addToBody(function);
    functionDefinition.addParameter(request);
    functionDefinition.addParameter(event);
    functionDefinition.addParameter(data);
   
    return functionDefinition;
  }
View Full Code Here

     * (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

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

    function.addParameter(ref);
    String ajaxFunc = function.toScript();
       
    Map<String, Object> ajaxOptions = buildEventOptions(context, toolTip, targetClientId);
    ajaxOptions.putAll(getParamsMap(context, toolTip));
    JSFunctionDefinition completeFunc = getUtils().getAsEventHandler(context, component, "oncomplete", "; return true;");
    JSFunctionDefinition hideFunc = getUtils().getAsEventHandler(context, component,"onhide", "; return true;");
    JSFunctionDefinition showFunc = getUtils().getAsEventHandler(context, component,"onshow", "; return true;");
   
    Map<JSReference, Object> funcMap = new HashMap<JSReference, Object>();
    funcMap.put(new JSReference("oncomplete"), completeFunc);
    funcMap.put(new JSReference("onhide"), hideFunc);
    funcMap.put(new JSReference("onshow"), showFunc);
View Full Code Here

TOP

Related Classes of org.ajax4jsf.javascript.JSFunctionDefinition

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.