Package org.ajax4jsf.javascript

Examples of org.ajax4jsf.javascript.JSFunction


        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


    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 void writeSubmitFunction(FacesContext context, UICalendar calendar)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();

    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(calendar,
        context, AjaxRendererUtils.AJAX_FUNCTION_NAME);
    ajaxFunction.addParameter(JSReference.NULL);
   
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put(calendar.getClientId(context) + CURRENT_DATE_PRELOAD, Boolean.TRUE);
   
    Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, calendar, params);
    options.put("calendar", JSReference.THIS);

    String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
    JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
    oncompleteDefinition.addParameter("request");
    oncompleteDefinition.addParameter("event");
    oncompleteDefinition.addParameter("data");
    oncompleteDefinition.addToBody("this.calendar.load(data, true);");
    if (oncomplete != null) {
      oncompleteDefinition.addToBody(oncomplete);
    }

    options.put("oncomplete", oncompleteDefinition);
    JSReference requestValue = new JSReference("requestValue");
    ajaxFunction.addParameter(options);
    JSFunctionDefinition definition = new JSFunctionDefinition();
    definition.addParameter(requestValue);
    definition.addToBody(ajaxFunction);
    writer.write(definition.toScript());
  }
View Full Code Here

  }

  public static Object formatDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    JSFunction result = new JSFunction("new Date");
    result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));

    return result;
  }
View Full Code Here

  public static Object formatSelectedDate(TimeZone timeZone, Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeZone(timeZone);
    calendar.setTime(date);
    JSFunction result = new JSFunction("new Date");
    result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
    result
        .addParameter(Integer.valueOf(calendar
            .get(Calendar.HOUR_OF_DAY)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
    result.addParameter(new Integer(0));
    return result;
  }
View Full Code Here

        }
    }

    public String createClientDataTable(FacesContext context,
            UIExtendedDataTable table) {
        JSFunction function = new JSFunction("new ExtendedDataTable.DataTable");
        function.addParameter(table.getBaseClientId(context));
        ScriptOptions scriptOptions = new ScriptOptions(table);
        // add on resize column AJAX function
        scriptOptions.addOption(ON_RESIZE_FUNCTION, getOnResizeFunctionDef(
                context, table));
        scriptOptions.addOption(SORT_FUNCTION, getSortFunctionDef(context,
                table));
        scriptOptions.addOption(GROUP_FUNCTION, getGroupFunctionDef(context,
                table));
        scriptOptions.addOption(SHOW_MENU_FUNCTION, getShowMenuFunction(
                context, table));
        scriptOptions.addOption(ENABLE_CONTEXT_MENU,table.getAttributes().get(ENABLE_CONTEXT_MENU));
        /* Not needed if we do not save open/close state */
        scriptOptions.addOption(ON_GROUP_TOGGLE_FUNCTION,
                getOnGroupToggleFunctionDef(context, table));
        scriptOptions.addOption("minColumnWidth", MIN_COLUMN_WIDTH);
        composite.mergeScriptOptions(scriptOptions, context, table);
        function.addParameter(scriptOptions);
        return function.toScript();
    }
View Full Code Here

        definition.addToBody("" +
            "if (ascending != null){"+
            "  options.parameters['" + SORT_DIR_PARAMETER + "'] = (ascending ? '"+SORT_DIR_PARAMETER_ASC+"':'"+SORT_DIR_PARAMETER_DESC+"');"+
            "}"
        );
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table,
                context);
        ajaxFunction.addParameter(new JSReference("options"));
        definition.addToBody(ajaxFunction.toScript()).addToBody(";\n");
        return definition;
    }// getSortFunctionDef
View Full Code Here

                context, table);
        if (onAjaxCompleteFunction != null) {
            requestOpts.put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
                    onAjaxCompleteFunction);
        }
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table,
                context);
        ajaxFunction.addParameter(requestOpts);
        return ajaxFunction;
    }// getSortFunction 
View Full Code Here

                context, table);
        if (onAjaxCompleteFunction != null) {
            requestOpts.put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
                    onAjaxCompleteFunction);
        }
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table,
                context);
        ajaxFunction.addParameter(requestOpts);
        return ajaxFunction;
    }// getGroupFunction
View Full Code Here

        }
        definition.addToBody("var options = ").addToBody(
                ScriptUtils.toScript(eventOptions)).addToBody(";\n");
        definition.addToBody("options.parameters['" + GROUP_FILTER_PARAMETER
                + "'] = columnId;\n");
        JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(table,
                context);
        ajaxFunction.addParameter(new JSReference("options"));
        definition.addToBody(ajaxFunction.toScript()).addToBody(";\n");
        return definition;
    }// getGroupFunctionDef
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.