Refine search
public void prepareChartDate() { // Produce you JSON string (I use Gson here) RequestContext reqCtx = RequestContext.getCurrentInstance(); reqCtx.addCallbackParam("chartData", jsonString); }
public void save() { RequestContext requestContext = RequestContext.getCurrentInstance(); requestContext.execute("dialog.hide()"); }
protected void encodeHiddenSelect(FacesContext context, AutoComplete ac, String clientId, List<String> values) throws IOException { ResponseWriter writer = context.getResponseWriter(); String id = clientId + "_hinput"; writer.startElement("select", null); writer.writeAttribute("id", id, null); writer.writeAttribute("name", id, null); writer.writeAttribute("multiple", "multiple", null); writer.writeAttribute("class", "ui-helper-hidden-accessible", null); if (ac.isDisabled()) { writer.writeAttribute("disabled", "disabled", "disabled"); } for (String value : values) { writer.startElement("option", null); writer.writeAttribute("value", value, null); writer.writeAttribute("selected", "selected", null); writer.endElement("option"); } if (RequestContext.getCurrentInstance().getApplicationContext().getConfig().isClientSideValidationEnabled()) { renderValidationMetadata(context, ac); } writer.endElement("select"); }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); PrimeConfiguration cc = RequestContext.getCurrentInstance(context).getApplicationContext().getConfig(); ProjectStage projectStage = context.getApplication().getProjectStage(); boolean csvEnabled = cc.isClientSideValidationEnabled(); writer.startElement("head", component); writer.writeAttribute("id", component.getClientId(context), "id"); UIComponent first = component.getFacet("first"); if (first != null) { first.encodeAll(context); String themeParamValue = RequestContext.getCurrentInstance(context).getApplicationContext().getConfig().getTheme(); ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression ve = expressionFactory.createValueExpression(elContext, themeParamValue, String.class); writer.startElement("script", null); writer.writeAttribute("type", "text/javascript", null); writer.write("if(window.PrimeFaces){");
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); RemoteCommand command = (RemoteCommand) component; AjaxSource source = (AjaxSource) command; AjaxRequestBuilder builder = RequestContext.getCurrentInstance(context).getAjaxRequestBuilder(); .form(form.getClientId(context)) .process(component, source.getProcess()) .update(component, source.getUpdate()) writer.startElement("script", command); writer.writeAttribute("id", clientId, null); writer.writeAttribute("type", "text/javascript", null); writer.write(name + " = function() {");
public void save() { FacesContext context = FacesContext.getCurrentInstance(); RequestContext requestContext = RequestContext.getCurrentInstance(); ResourceBundle bundle = context.getApplication().getResourceBundle( context, "msg"); Map<String, String> parameters = context.getExternalContext() .getRequestParameterMap(); String param = parameters.get("close"); suggestNewName(); requestContext.update("new-form"); requestContext.execute("PF('newReportDialog').show()"); requestContext.update(Arrays.asList(new String[] { "toolbar-form:toolbar", "repository-form:repository-panel", "growl" })); requestContext.update("close-form"); title, message)); requestContext.execute("enableSave(false);");
FacesContext context = FacesContext.getCurrentInstance(); ResourceBundle bundle = context.getApplication() .getResourceBundle(context, "msg"); String message = bundle.getString("error.filter.message"); context.addMessage(null, new FacesMessage( FacesMessage.SEVERITY_WARN, title, message)); return; filterPanel.getChildren().add(panel); RequestContext.getCurrentInstance().execute("PF('filterDialog').show();");
FacesContext context = FacesContext.getCurrentInstance(); AutoUpdatable component = (AutoUpdatable) cse.getSource(); String clientId = ((UIComponent) component).getClientId(context); if (component.isAutoUpdate() && context.isPostback()) { if (!RequestContext.getCurrentInstance(context).isIgnoreAutoUpdate() && !context.getPartialViewContext().getRenderIds().contains(clientId)) { context.getPartialViewContext().getRenderIds().add(clientId);
if (uploadWarningMessage != null) { if (uploadWarningMessageIsNotAnError) { FacesContext.getCurrentInstance().addMessage(uploadComponentId, new FacesMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("dataset.file.uploadWarning"), uploadWarningMessage)); } else { FacesContext.getCurrentInstance().addMessage(uploadComponentId, new FacesMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("dataset.file.uploadWarning"), uploadWarningMessage)); RequestContext context = RequestContext.getCurrentInstance(); RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup"); context.execute("PF('fileTypeDifferentPopup').show();");
protected void renderPassThruAttributes(FacesContext context, UIComponent component, String[] attrs, String[] ignoredAttrs) throws IOException { ResponseWriter writer = context.getResponseWriter(); //pre-defined attributes for (String attribute : attrs) { if (isIgnoredAttribute(attribute, ignoredAttrs)) { continue; } Object value = component.getAttributes().get(attribute); if (shouldRenderAttribute(value)) { writer.writeAttribute(attribute, value.toString(), attribute); } } //dynamic attributes if (RequestContext.getCurrentInstance(context).getApplicationContext().getConfig().isAtLeastJSF22()) { Jsf22Helper.renderPassThroughAttributes(context, component); } }
public boolean canComputeAllFiles(boolean isCartCompute){ for (FileMetadata fmd : workingVersion.getFileMetadatas()) { if (!fileDownloadHelper.canDownloadFile(fmd)) { RequestContext requestContext = RequestContext.getCurrentInstance(); requestContext.execute("PF('computeInvalid').show()"); return false; } } if (!isCartCompute) { try { FacesContext.getCurrentInstance().getExternalContext().redirect(getComputeUrl()); } catch (IOException ioex) { logger.warning("Failed to issue a redirect."); } } return true; } /*
protected NavigationCase findNavigationCase(FacesContext context, UIOutcomeTarget outcomeTarget) { ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler(); String outcome = outcomeTarget.getOutcome(); if (outcome == null) { outcome = context.getViewRoot().getViewId(); } if (RequestContext.getCurrentInstance(context).getApplicationContext().getConfig().isAtLeastJSF22()) { if (outcomeTarget instanceof UIComponent) { String toFlowDocumentId = (String) ((UIComponent) outcomeTarget).getAttributes().get(ActionListener.TO_FLOW_DOCUMENT_ID_ATTR_NAME); if (toFlowDocumentId != null) { return navigationHandler.getNavigationCase(context, null, outcome, toFlowDocumentId); } } } return navigationHandler.getNavigationCase(context, null, outcome); }
protected String resolveTheme(FacesContext context) { String theme = null; String themeConfigValue = RequestContext.getCurrentInstance(context).getApplicationContext().getConfig().getMobileTheme(); if (themeConfigValue != null) { ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression ve = expressionFactory.createValueExpression(elContext, themeConfigValue, String.class); theme = ve.isLiteralText() ? themeConfigValue : (String) ve.getValue(elContext); } return theme; }
protected void encodeOnloadScripts(ResponseWriter writer) throws IOException { List<String> scripts = RequestContext.getCurrentInstance().getScriptsToExecute(); if (!scripts.isEmpty()) { writer.startElement("script", null); writer.writeAttribute("type", "text/javascript", null); writer.write("$(function(){"); for (int i = 0; i < scripts.size(); i++) { writer.write(scripts.get(i)); writer.write(';'); } writer.write("});"); writer.endElement("script"); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { Lifecycle lifecycle = (Lifecycle) component; String clientId = lifecycle.getClientId(context); ResponseWriter writer = context.getResponseWriter(); writer.startElement("table", lifecycle); writer.writeAttribute("id", clientId, "id"); writer.writeAttribute("class", Lifecycle.STYLE_CLASS, null); writer.startElement("tr", null); for (PhaseId phaseId : PhaseId.VALUES) { if (phaseId != PhaseId.ANY_PHASE) { encodePhase(phaseId, phaseId.toString(), context, writer); } } encodePhase(PhaseId.ANY_PHASE, "ALL", context, writer); writer.endElement("tr"); writer.endElement("table"); WidgetBuilder wb = RequestContext.getCurrentInstance(context).getWidgetBuilder(); wb.initWithDomReady("Lifecycle", lifecycle.resolveWidgetVar(), clientId); wb.finish(); }
/** * Invoke this method to commit the most recent set of ajax updates and restart the tracking of changes. Use this when you have processes the updates to the * model and are confident that any changes made to this point can be cleared (likely because you have persisted those changes). */ public void commitUpdates() { resetSubmitted(); final FacesContext context = FacesContext.getCurrentInstance(); if (context.getPartialViewContext().isPartialRequest()) { final StringBuilder eval = new StringBuilder(); final String jsVar = resolveWidgetVar(); eval.append("PF('").append(jsVar).append("')").append(".clearDataInput();"); RequestContext.getCurrentInstance().getScriptsToExecute().add(eval.toString()); } }
public static RequestContext getCurrentInstance() { return getCurrentInstance(FacesContext.getCurrentInstance()); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); KeyFilter keyFilter = (KeyFilter) component; target = component.getParent(); String targetClientId = target instanceof InputHolder ? ((InputHolder) target).getInputClientId() : target.getClientId(); WidgetBuilder wb = RequestContext.getCurrentInstance(context).getWidgetBuilder(); wb.initWithDomReady(KeyFilter.class.getSimpleName(), keyFilter.resolveWidgetVar(), keyFilter.getClientId(context)); wb.attr("target", targetClientId);
@Override public void endDocument() throws IOException { FacesContext context = FacesContext.getCurrentInstance(); RequestContext requestContext = RequestContext.getCurrentInstance(context); if (requestContext != null) { try { if (context.isValidationFailed()) { requestContext.addCallbackParam("validationFailed", true); } encodeCallbackParams(requestContext.getCallbackParams()); encodeScripts(requestContext); } catch (Exception exception) { throw new AbortProcessingException(exception); } } wrapped.endDocument(); }
protected String buildAjaxRequest(FacesContext context, AjaxSource source, UIComponent form) { UIComponent component = (UIComponent) source; String clientId = component.getClientId(context); AjaxRequestBuilder builder = RequestContext.getCurrentInstance(context).getAjaxRequestBuilder(); builder.init() .source(clientId) .form(SearchExpressionFacade.resolveClientId(context, component, source.getForm())) .process(component, source.getProcess()) .update(component, source.getUpdate()) .async(source.isAsync()) .global(source.isGlobal()) .delay(source.getDelay()) .timeout(source.getTimeout()) .partialSubmit(source.isPartialSubmit(), source.isPartialSubmitSet(), source.getPartialSubmitFilter()) .resetValues(source.isResetValues(), source.isResetValuesSet()) .ignoreAutoUpdate(source.isIgnoreAutoUpdate()) .onstart(source.getOnstart()) .onerror(source.getOnerror()) .onsuccess(source.getOnsuccess()) .oncomplete(source.getOncomplete()) .params(component); if (form != null) { builder.form(form.getClientId(context)); } builder.preventDefault(); return builder.build(); }