public static JSFunction createFunction(String name) { JSFunction function = new JSFunction(name); function.addParameter(request); function.addParameter(event); function.addParameter(data); return function; }
public static Object formatSelectedDate(TimeZone timeZone, Date date) { FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractCalendar calendarInstance = (AbstractCalendar) AbstractCalendar.getCurrentComponent(facesContext); Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarInstance); calendar.setTimeZone(timeZone); calendar.setTime(date); JSFunction result = new JSFunction("new Date"); result.addParameter(calendar.get(Calendar.YEAR)); result.addParameter(calendar.get(Calendar.MONTH)); result.addParameter(calendar.get(Calendar.DATE)); result.addParameter(calendar.get(Calendar.HOUR_OF_DAY)); result.addParameter(calendar.get(Calendar.MINUTE)); result.addParameter(0); return result; }
public static Object formatSelectedDate(TimeZone timeZone, Date date) { FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractCalendar calendarInstance = (AbstractCalendar) AbstractCalendar.getCurrentComponent(facesContext); Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarInstance); calendar.setTimeZone(timeZone); calendar.setTime(date); JSFunction result = new JSFunction("new Date"); result.addParameter(calendar.get(Calendar.YEAR)); result.addParameter(calendar.get(Calendar.MONTH)); result.addParameter(calendar.get(Calendar.DATE)); result.addParameter(calendar.get(Calendar.HOUR_OF_DAY)); result.addParameter(calendar.get(Calendar.MINUTE)); result.addParameter(0); return result; }
public static Object formatDate(Date date) { FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractCalendar calendarInstance = (AbstractCalendar) AbstractCalendar.getCurrentComponent(facesContext); Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarInstance); calendar.setTime(date); JSFunction result = new JSFunction("new Date"); result.addParameter(calendar.get(Calendar.YEAR)); result.addParameter(calendar.get(Calendar.MONTH)); result.addParameter(calendar.get(Calendar.DATE)); return result; }
public static Object formatDate(Date date) { FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractCalendar calendarInstance = (AbstractCalendar) AbstractCalendar.getCurrentComponent(facesContext); Calendar calendar = CalendarHelper.getCalendar(facesContext, calendarInstance); calendar.setTime(date); JSFunction result = new JSFunction("new Date"); result.addParameter(calendar.get(Calendar.YEAR)); result.addParameter(calendar.get(Calendar.MONTH)); result.addParameter(calendar.get(Calendar.DATE)); return result; }
public void buildScript(ResponseWriter writer, FacesContext context, UIComponent component, Map<?, ?> buttons, Map<?, ?> digitals) throws IOException { JSFunction function = new JSFunction("new RichFaces.ui.DataScroller"); function.addParameter(component.getClientId(context)); Map<String, Object> options = new HashMap<String, Object>(); options.put("buttons", buttons); options.put("digitals", digitals); options.put("currentPage", (Integer) component.getAttributes().get("page")); function.addParameter(getSubmitFunction(context, component)); function.addParameter(options); writer.write(function.toString()); }
public void buildScript(ResponseWriter writer, FacesContext context, UIComponent component, Map<?, ?> buttons, Map<?, ?> digitals) throws IOException { JSFunction function = new JSFunction("new RichFaces.ui.DataScroller"); function.addParameter(component.getClientId(context)); Map<String, Object> options = new HashMap<String, Object>(); options.put("buttons", buttons); options.put("digitals", digitals); options.put("currentPage", (Integer) component.getAttributes().get("page")); function.addParameter(getSubmitFunction(context, component)); function.addParameter(options); writer.write(function.toString()); }
public String toScript() { String result = null; if (!handlers.isEmpty()) { if (handlers.size() == 1) { result = handlers.get(0); } else { JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT); for (String handler : handlers) { jsFunction.addParameter(handler); } result = jsFunction.toScript(); } } return result; }
public String toScript() { String result = null; if (!handlers.isEmpty()) { if (handlers.size() == 1) { result = handlers.get(0); } else { JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT); for (String handler : handlers) { jsFunction.addParameter(handler); } result = jsFunction.toScript(); } } return result; }
public String toScript() { String result = null; if (!handlers.isEmpty()) { if (handlers.size() == 1) { result = handlers.get(0); } else { JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT); for (String handler : handlers) { jsFunction.addParameter(handler); } result = jsFunction.toScript(); } } return result; }
/** * @return JavaScript eventString. Rebuild on every call, since * can be in loop ( as in dataTable ) with different parameters. */ public String getEventString() { 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(); }
private DnDScript buildClientScript(FacesContext facesContext, UIComponent component) { DnDScript script = null; String scriptName = getScriptName(); if (!"".equals(scriptName)) { JSFunction function = new JSFunction(scriptName); function.addParameter(component.getClientId(facesContext)); function.addParameter(getOptions(facesContext, component)); script = createScript(function.toScript()); } return script; }
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; }
private DnDScript buildClientScript(FacesContext facesContext, UIComponent component) { DnDScript script = null; String scriptName = getScriptName(); if (!"".equals(scriptName)) { JSFunction function = new JSFunction(scriptName); function.addParameter(component.getClientId(facesContext)); function.addParameter(getOptions(facesContext, component)); script = createScript(function.toScript()); } return script; }
public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException { AbstractDataTable dataTable = (AbstractDataTable) dataTableBase; writer.startElement(HtmlConstants.SCRIPT_ELEM, dataTable); writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.JAVASCRIPT_TYPE, null); JSFunction function = new JSFunction("new RichFaces.ui.DataTable"); function.addParameter(dataTable.getClientId(facesContext)); AjaxOptions ajaxOptions = AjaxRendererUtils.buildEventOptions(facesContext, dataTable); Map<String, Object> options = new HashMap<String, Object>(); options.put("ajaxEventOptions", ajaxOptions.getParameters()); function.addParameter(options); writer.writeText(function.toScript(), null); writer.endElement(HtmlConstants.SCRIPT_ELEM); }
public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException { AbstractDataTable dataTable = (AbstractDataTable) dataTableBase; writer.startElement(HtmlConstants.SCRIPT_ELEM, dataTable); writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.JAVASCRIPT_TYPE, null); JSFunction function = new JSFunction("new RichFaces.ui.DataTable"); function.addParameter(dataTable.getClientId(facesContext)); AjaxOptions ajaxOptions = AjaxRendererUtils.buildEventOptions(facesContext, dataTable); Map<String, Object> options = new HashMap<String, Object>(); options.put("ajaxEventOptions", ajaxOptions.getParameters()); function.addParameter(options); writer.writeText(function.toScript(), null); writer.endElement(HtmlConstants.SCRIPT_ELEM); }
protected void encodeNotification(FacesContext facesContext, UIComponent component, Map<String, Object> options) throws IOException { JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class); for (MessageForRender message : getVisibleMessages(facesContext, component)) { JSFunction notifyCall = new JSFunction("RichFaces.ui.Notify"); Map<String, Object> optionsCopy = new LinkedHashMap<String, Object>(options); addMessageSpecificAttributes(message, facesContext, component, optionsCopy); notifyCall.addParameter(optionsCopy); javaScriptService.addPageReadyScript(facesContext, notifyCall); message.rendered(); } }
protected void encodeNotification(FacesContext facesContext, UIComponent component, Map<String, Object> options) throws IOException { JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class); for (MessageForRender message : getVisibleMessages(facesContext, component)) { JSFunction notifyCall = new JSFunction("RichFaces.ui.Notify"); Map<String, Object> optionsCopy = new LinkedHashMap<String, Object>(options); addMessageSpecificAttributes(message, facesContext, component, optionsCopy); notifyCall.addParameter(optionsCopy); javaScriptService.addPageReadyScript(facesContext, notifyCall); message.rendered(); } }
public String createClientScrollableGrid(FacesContext context, UIScrollableDataTable grid) { ScrollableDataTableOptions options = new ScrollableDataTableOptions(grid); 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(); }
protected void encodeControl(FacesContext context, UIComponent component) throws IOException { AbstractCollapsibleSubTableToggler toggleControl = (AbstractCollapsibleSubTableToggler) component; AbstractCollapsibleSubTable subTable = findComponent(context, toggleControl); if (subTable != null) { boolean expanded = subTable.isExpanded(); ResponseWriter writer = context.getResponseWriter(); encodeControl(context, writer, toggleControl, expanded, true); encodeControl(context, writer, toggleControl, !expanded, false); JSFunction jsFunction = new JSFunction("new RichFaces.ui.CollapsibleSubTableToggler"); String toggleId = toggleControl.getClientId(context); jsFunction.addParameter(toggleId); Map<String, Object> options = encodeOptions(context, toggleControl, subTable); jsFunction.addParameter(options); writer.startElement(HtmlConstants.SCRIPT_ELEM, subTable); writer.writeText(jsFunction.toScript(), null); writer.endElement(HtmlConstants.SCRIPT_ELEM); } }