Package org.ajax4jsf.javascript

Examples of org.ajax4jsf.javascript.JSFunction


        return ajaxFunction;
    }

    protected JSFunction getPreSendAjaxRequestFunction(FacesContext context,
            UIDataTable table) {
        return new JSFunction(getJavaScriptVarName(context, table)
                + ".preSendAjaxRequest");
    }
View Full Code Here


    protected String buildAjaxFunction(FacesContext context,
            UIComponent column, boolean sortable,
            JSFunctionDefinition onAjaxCompleteFunction) {
        UIComponent table = column.getParent();
        String id = table.getClientId(context);
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table,
                context);
        Map<String, Object> eventOptions = AjaxRendererUtils.buildEventOptions(
                context, table);
        @SuppressWarnings("unchecked")
        Map<String, Object> parameters = (Map<String, Object>) eventOptions
                .get("parameters");

        parameters.put(id, SORT_FILTER_PARAMETER);
        if (sortable) {
            parameters.put(SORT_FILTER_PARAMETER, column.getClientId(context));
        }
        if (onAjaxCompleteFunction != null)
            eventOptions.put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
                    onAjaxCompleteFunction);
        ajaxFunction.addParameter(eventOptions);
        StringBuffer buffer = new StringBuffer();
        ajaxFunction.appendScript(buffer);

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

      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

      script.append("fireExpansionEvent(this);");
    }
   
    if (UITree.SWITCH_AJAX.equals(tree.getSwitchType())) {
      UITreeNode nodeFacet = tree.getNodeFacet();
      JSFunction function = AjaxRendererUtils.buildAjaxFunction(nodeFacet,
          context);
      Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
          nodeFacet);
      Map parameters = (Map) eventOptions.get("parameters");
      parameters.remove(id);

      parameters.put(id + NODE_EXPANDED_INPUT_SUFFIX, String.valueOf(!expanded));
      parameters.put(id + AJAX_EXPANDED_SUFFIX, Boolean.TRUE);
     
      function.addParameter(eventOptions);

      StringBuffer buffer = new StringBuffer();
      buffer.append(script);
      buffer.append(";");
      function.appendScript(buffer);
      buffer.append(";");
      return buffer.toString();
     
    } else if (UITree.SWITCH_SERVER.equals(tree.getSwitchType())) {
      String paramName = id + NODE_EXPANDED_INPUT_SUFFIX;
View Full Code Here

    while(columns.hasNext() && !shouldRender) {
      UIComponent next = columns.next();
      shouldRender = (next instanceof Column) && ((Column)next).isSortable();
    }
    if (shouldRender) {
      JSFunction function = new JSFunction("new RichFaces.DataTable");
      function.addParameter(component.getBaseClientId(context));
      ScriptOptions scriptOptions = new ScriptOptions(component);
      scriptOptions.addOption("sortMode", new JSFunction("new RichFaces.SortMode.Single"));
      function.addParameter(scriptOptions);
      getUtils().writeScript(context, component, function.toScript());
    }
  }
View Full Code Here

  }
 
  protected String buildAjaxFunction(FacesContext context, UIComponent column, boolean sortable) {
    UIComponent table = column.getParent();
    String id = table.getClientId(context);
    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table, context);
    Map<String, Object> eventOptions = AjaxRendererUtils.buildEventOptions(context, table);
   
   
    @SuppressWarnings("unchecked")
    Map<String, Object> parameters =
      (Map<String, Object>) eventOptions.get("parameters");
   
   
    parameters.put(id, SORT_FILTER_PARAMETER);
    if (sortable) {
      parameters.put(SORT_FILTER_PARAMETER, column.getClientId(context));
    }
    ajaxFunction.addParameter(eventOptions);
    StringBuffer buffer = new StringBuffer();
    ajaxFunction.appendScript(buffer);
   
    return buffer.toString();
  }
View Full Code Here

   
    options.addOption("normalizedId", getNormalizedId(context, grid));
   
    composite.mergeScriptOptions(options, context, grid);
   
    JSFunction function = new JSFunction("new ClientUI.controls.grid.ScrollableGrid");
    function.addParameter(options);
    return function.toScript();
  }
View Full Code Here

    ScrollableDataTableRendererState.restoreState(context);
  }
 
  public String getRowsAjaxUpdate(FacesContext context, UIScrollableDataTable grid){
   
    JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
    Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, grid);
    options.put("oncomplete", AjaxFunctionBuilder.getOnComplete(context, grid, AjaxFunctionBuilder.SCROLL));

    @SuppressWarnings("unchecked")
    Map<String, Object> parametersMap = (Map<String, Object>) options.get("parameters");
   
    parametersMap.put(grid.getBaseClientId(context) + ":scroll", "");
    function.addParameter(options);
    String completeFunction = function.toScript()+"; return false;";
   
    return completeFunction;
   
  }
View Full Code Here

        String targetId = targetComponent.getClientId(context);

        Map attributes = component.getAttributes();
        StringBuffer script = new StringBuffer(" new ");
        // Build ajax function call
        JSFunction submitSuggest = AjaxRendererUtils.buildAjaxFunction(
                component, context, "RichFaces.Suggestion");
  submitSuggest.addParameter(targetId);
        submitSuggest.addParameter(component.getClientId(context));
        submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
        Map options = AjaxRendererUtils.buildEventOptions(context, component);
        options.put("popup", component.getClientId(context));
        for (int i = 0; i < OPTIONS.length; i++) {
            String option = OPTIONS[i];
            Object value = attributes.get(option);
            if (null != value) {
                options.put(option, value);
            }
        }
        // If ajax queue name not set, put clientId
        String eventsQueue = (String) options.get("eventsQueue");
        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
                || attributes.get("fetchValue") != null) {
            options.put("select", attributes.get("selectValueClass"));
        }
       
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        options.put("usingSuggestObjects", suggestionBox.isUsingSuggestObjects());

        // pass "zindex" attribute to js though the "options" attribute
        options.put("zindex", suggestionBox.getZindex());

        submitSuggest.addParameter(options);
        script.append(submitSuggest.toScript()).append(";\n");
        return "Richfaces.onAvailable('" + targetId + "', function() {" + script.toString() + "});";
    }
View Full Code Here

    }
   
    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

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.