Package org.ajax4jsf.javascript

Examples of org.ajax4jsf.javascript.JSFunction


  private static final JSReference data = new JSReference("data");
  public static final int SORT = 0;
  public static final int SCROLL = 1;
 
  public static JSFunction createFunction(String name) {
    JSFunction function = new JSFunction(name);
    function.addParameter(request);
    function.addParameter(event);
    function.addParameter(data);
   
    return function;
 
View Full Code Here


    return function;
 
   
  public static JSFunctionDefinition getOnComplete(FacesContext context, UIScrollableDataTable grid, int type) {
   
    JSFunction function = null;
   
    switch (type) {
      case SCROLL:
        function = createFunction(ScrollableDataTableBaseRenderer.getJavaScriptVarName(context, grid) + ".onScrollComplete");
        break;
View Full Code Here

    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

        params.put(name, value);
    }
      }

      for (String attachToId : attachToIds) {
    JSFunction attachContextMenuFunction = new JSFunction(baseJSFucntionName);
    UIComponent target = RendererUtils.getInstance().findComponentFor(context, contextMenu, attachToId);
    String clientId = (target != null) ? target.getClientId(context) : attachToId;     

    attachContextMenuFunction.addParameter(clientId);
    attachContextMenuFunction.addParameter(contextMenu.getEvent());
    attachContextMenuFunction.addParameter(params);

    if (isImmediate) {
        attachContextMenuBuffer.append(attachContextMenuFunction.toScript());
    } else {
      if (isOnAvailable) {
        JSFunction availableFunction = new JSFunction("Richfaces.onAvailable");
          availableFunction.addParameter(clientId);
        availableFunction.addParameter(new JSBind(attachContextMenuFunction, "contextMenu"));
          attachContextMenuBuffer.append(availableFunction.toScript());
         
      } else if (isOnLoad) {
          JSFunction onloadFunction = new JSFunction("jQuery(document).ready");
          onloadFunction.addParameter(new JSBind(attachContextMenuFunction, "contextMenu"));

          attachContextMenuBuffer.append(onloadFunction.toScript());
      }
    }

    attachContextMenuBuffer.append(";");
      }
View Full Code Here

     */
    public void renderDragSupport(UIColumn column, String dragSourceId,
            String indicatorId, String dragLabel) throws IOException {
      String varName = "DnD_ExtSimpleDraggable_"+column.getId().replaceAll("[^A-Za-z0-9_]", "_");
        StringBuffer buffer = new StringBuffer("delete " + varName + ";\nvar " + varName + " = ");
        JSFunction function = new JSFunction("new DnD.ExtSimpleDraggable");
        function.addParameter(dragSourceId);
        String dragSourceScriptId = column.getClientId(context) + ":"
                + DRAG_SOURCE_SCRIPT_ID;
        ExtDraggableRendererContributor contributor = ExtDraggableRendererContributor
                .getInstance();
        ScriptOptions dragOptions = contributor.buildOptions(context, column,
                dragSourceScriptId, indicatorId);

        JSONObject dndParams = new JSONObject();
        try {
            dndParams.put("label", dragLabel == null ? "" : dragLabel);
        } catch (JSONException e) {
        }
        dragOptions.addOption("dndParams", dndParams.toString());

        function.addParameter(dragOptions);
        function.appendScript(buffer);

        String scriptContribution = contributor.getScriptContribution(context,
                column);
        if (scriptContribution != null && scriptContribution.length() != 0) {
            buffer.append(scriptContribution);
View Full Code Here

        // DropzoneRendererContributor.getInstance();
        ExtDropzoneRendererContributor contributor = ExtDropzoneRendererContributor
                .getInstance();
        String varName = "DnD_ExtSimpleDropZone_"+column.getId().replaceAll("[^A-Za-z0-9_]", "_") + (before?"L":"R");
        StringBuffer buffer = new StringBuffer("delete " + varName + ";\nvar " + varName + " = ");
        JSFunction function = new JSFunction("new DnD.ExtSimpleDropZone");
        function.addParameter(dropTargetId);
        ScriptOptions dropOptions = contributor.buildOptions(context, column);
        JSONObject dndParams = new JSONObject();
        dropOptions.addOption("dndParams", dndParams.toString());

        function.addParameter(dropOptions);
        function.appendScript(buffer);

        String dropTargetScriptId = column.getClientId(context) + ":"
                + DROP_TARGET_SCRIPT_ID
                + (before ? DROP_TARGET_BEFORE : DROP_TARGET_AFTER);
        String scriptContribution = contributor.getScriptContribution(context,
View Full Code Here

    eventsMap.put(new JSReference("showEvent"), eventShow);
    eventsMap.put(new JSReference("hideEvent"), eventHide);
    eventsMap.put(new JSReference("delay"), new Integer(toolTip.getShowDelay()));
    eventsMap.put(new JSReference("hideDelay"), new Integer(toolTip.getHideDelay()));
   
    JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context);
    JSReference ref = new JSReference("ajaxOptions");
    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;");
View Full Code Here

    definition.addToBody("options.parameters['" + DROP_TARGET_ID + "'] = '" + component.getClientId(context) + "';");
    //TODO nick - 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(component, context);
    dropFunction.addParameter(new JSReference("options"));
   
    definition.addToBody(dropFunction.toScript()).addToBody(";");
    definition.appendScript(result);
    result.append(";");

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

  public String getFunction(FacesContext context, UIAjaxFunction component) {
    StringBuffer script = new StringBuffer(component.getName()).append("=");
    JSFunctionDefinition func = new JSFunctionDefinition();
    //func.setName(component.getName());
    // Create AJAX Submit function.
    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
        component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
    Map options = AjaxRendererUtils.buildEventOptions(context, component);
    Map parameters = (Map) options.get("parameters");
    if (null == parameters) {
      parameters = new HashMap();
      options.put("parameters", parameters);
    }
    ajaxFunction.addParameter(JSReference.NULL);
    ajaxFunction.addParameter(options);
    // Fill parameters.
    for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
      UIComponent child = (UIComponent) 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

  {
    String targetId = HtmlUtil.idsToIdSelector(getFor());

    targetId = HtmlUtil.expandIdSelector(targetId, this, FacesContext.getCurrentInstance());
   
    JSFunction invocation = new JSFunction("Richfaces.componentControl.performOperation");
    invocation.addParameter(new JSReference("event"));
    invocation.addParameter(targetId);
    invocation.addParameter(getOperation());
    invocation.addParameter(new JSReference("{" + getEncodedParametersMap() + "}"));
    invocation.addParameter(Boolean.valueOf(isDisableDefault()));
   
    return invocation.toScript();


  }
View Full Code Here

TOP

Related Classes of org.ajax4jsf.javascript.JSFunction

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.