protected Object chain(String firstHandler, String secondHandler) { if (isNullOrEmpty(firstHandler) && isNullOrEmpty(secondHandler)) { return null; } if (isNullOrEmpty(firstHandler)) { return secondHandler; } if (isNullOrEmpty(secondHandler)) { return firstHandler; } return new JSFunction("return jsf.util.chain", JSReference.THIS, JSReference.EVENT, firstHandler, secondHandler) .toScript(); }
protected Object chain(String firstHandler, String secondHandler) { if (isNullOrEmpty(firstHandler) && isNullOrEmpty(secondHandler)) { return null; } if (isNullOrEmpty(firstHandler)) { return secondHandler; } if (isNullOrEmpty(secondHandler)) { return firstHandler; } return new JSFunction("return jsf.util.chain", JSReference.THIS, JSReference.EVENT, firstHandler, secondHandler) .toScript(); }
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; }
public String createCallScript(String clientId, String sourceId) { JSFunction callFunction = new JSFunction(getName(), EVENT_REF, JSReference.THIS); return callFunction.toScript(); }
public String createCallScript(String clientId, String sourceId) { JSFunction callFunction = new JSFunction(getName(), EVENT_REF, clientId, null != sourceId ? sourceId : JSReference.THIS); return callFunction.toScript(); }
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; }
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 encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) throws IOException { if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) { PartialResponseWriter writer = context.getPartialViewContext().getPartialResponseWriter(); writer.startUpdate(getSelectionStateInputId(context, component)); encodeSelectionStateInput(context, component); writer.endUpdate(); JSFunction function = new JSFunction("RichFaces.$", component.getClientId(context)); ExtendedPartialViewContext partialContext = ExtendedPartialViewContext.getInstance(context); partialContext.appendOncomplete(function.toScript() + ".__updateSelectionFromInput();"); } else { throw new IllegalArgumentException(metaComponentId); } // TODO Auto-generated method stub }
public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) throws IOException { if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) { PartialResponseWriter writer = context.getPartialViewContext().getPartialResponseWriter(); writer.startUpdate(getSelectionStateInputId(context, component)); encodeSelectionStateInput(context, component); writer.endUpdate(); JSFunction function = new JSFunction("RichFaces.component", component.getClientId(context)); ExtendedPartialViewContext partialContext = ExtendedPartialViewContext.getInstance(context); partialContext.appendOncomplete(function.toScript() + ".__updateSelectionFromInput();"); } else { throw new IllegalArgumentException(metaComponentId); } // TODO Auto-generated method stub }
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 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(); }
/** * @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(); }
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); } }
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); } }
private void encodeStyle(RendererState state) throws IOException { FacesContext context = state.getContext(); ResponseWriter writer = context.getResponseWriter(); UIDataTableBase table = state.getRow(); PartialViewContext pvc = context.getPartialViewContext(); if (!pvc.isAjaxRequest()) { writer.startElement("style", table); writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/css", null); writer.writeText(getCSSText(context, table), null); writer.endElement("style"); } else { writer.startElement(HtmlConstants.SCRIPT_ELEM, table); writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.TEXT_JAVASCRIPT_TYPE, null); String cssText = getCSSText(context, table); JSFunction function = new JSFunction("RichFaces.utils.addCSSText", cssText, table.getClientId(context) + ":st"); writer.writeText(function.toScript(), null); writer.endElement(HtmlConstants.SCRIPT_ELEM); } }
private void encodeStyle(RendererState state) throws IOException { FacesContext context = state.getContext(); ResponseWriter writer = context.getResponseWriter(); UIDataTableBase table = state.getRow(); PartialViewContext pvc = context.getPartialViewContext(); if (!pvc.isAjaxRequest()) { writer.startElement("style", table); writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/css", null); writer.writeText(getCSSText(context, table), null); writer.endElement("style"); } else { writer.startElement(HtmlConstants.SCRIPT_ELEM, table); writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.TEXT_JAVASCRIPT_TYPE, null); String cssText = getCSSText(context, table); JSFunction function = new JSFunction("RichFaces.utils.addCSSText", cssText, table.getClientId(context) + ":st"); writer.writeText(function.toScript(), null); writer.endElement(HtmlConstants.SCRIPT_ELEM); } }