protected void encodeFilter(FacesContext context, TreeTable tt, UIColumn column) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ResponseWriter writer = context.getResponseWriter(); UIComponent filterFacet = column.getFacet("filter"); String separator = String.valueOf(UINamingContainer.getSeparatorChar(context)); boolean disableTabbing = tt.getScrollWidth() != null; writer.startElement("input", null); writer.writeAttribute("id", filterId, null); writer.writeAttribute("name", filterId, null); writer.writeAttribute("class", filterStyleClass, null); writer.writeAttribute("value", filterValue, null); writer.startElement("div", null); writer.writeAttribute("class", TreeTable.COLUMN_CUSTOM_FILTER_CLASS, null); filterFacet.encodeAll(context); writer.endElement("div");
protected void encodePageLayout(FacesContext context, SelectOneRadio radio, List<SelectItem> selectItems) throws IOException { ResponseWriter writer = context.getResponseWriter(); Converter converter = radio.getConverter(); String name = radio.getClientId(context); String currentValue = ComponentUtils.getValueToRender(context, radio); for (int i = 0; i < selectItems.size(); i++) { SelectItem selectItem = selectItems.get(i); boolean disabled = selectItem.isDisabled() || radio.isDisabled(); String id = name + UINamingContainer.getSeparatorChar(context) + i; boolean selected = isSelected(context, radio, selectItem, currentValue); writer.startElement("tr", null); writer.startElement("td", null); encodeOption(context, radio, selectItem, id, name, converter, selected, disabled); writer.endElement("td"); writer.endElement("tr"); } }
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException { try { String viewID = facesContext.getViewRoot().getViewId(); String blockingFlag = (String) facesContext.getExternalContext() .getRequestMap().get("BlockingServlet"); String formId = form.getClientId(facesContext); + UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance()) + HIDDEN_FIELD)); if (dndType != null) { DnDCache.getInstance(facesContext, true).put( uiComponent.getClientId(facesContext), (HtmlPanelGroup) uiComponent, facesContext); StringBuffer dropCall = new StringBuffer(); String call = addJavascriptCalls(uiComponent, dndType, null, facesContext, dropCall); String clientId = uiComponent.getClientId(facesContext); Element script = domContext.createElement(HTML.SCRIPT_ELEM); script.setAttribute(HTML.ID_ATTR, ClientIdPool.get(clientId + "script"));
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { String togglerClientId = component.getClientId(context); togglerClientId = togglerClientId != null ? togglerClientId.replace(".", "-") : ""; RowState rowState = (RowState) context.getExternalContext().getRequestMap().get("rowState"); boolean expanded = rowState.isExpanded(); boolean expandable = rowState.isExpandable(); UIComponent parent = component.getParent(); while (!(parent instanceof DataTable)) { parent = parent.getParent(); } DataTable table = (DataTable)parent; DataModel model = table.getModel(); ResponseWriter writer = context.getResponseWriter(); ExpansionToggler toggler = (ExpansionToggler) component; String togglerClass = "ui-icon "; if (isRow) { String clientId = table.getClientId(context); for (Character c : clientId.substring(clientId.lastIndexOf(UINamingContainer.getSeparatorChar(context))+1).toCharArray()) if (c.equals('.')) chironWidth++; writer.startElement("div", null); writer.writeAttribute("class", DataTableConstants.ROW_TOGGLER_CONTAINER, null); writer.startElement("span", null); writer.writeAttribute("class", DataTableConstants.ROW_TOGGLER_SPAN, null); writer.writeAttribute("style", "width:"+ chironWidth * 15 + "px", null);
final DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent); String formClientId = uiComponent.getClientId(facesContext); root.setAttribute("id", formClientId); root.setAttribute("method", "post"); ExternalContext externalContext = facesContext.getExternalContext(); root.setAttribute("action", getAction(facesContext)); (String) uiComponent.getAttributes().get("styleClass"); if (styleClass != null) { root.setAttribute("class", styleClass); (String) uiComponent.getAttributes().get("acceptcharset"); if (acceptcharset != null) { root.setAttribute("accept-charset", acceptcharset); ", value: " + flowId); String flowParamId = formClientId + UINamingContainer.getSeparatorChar(facesContext) + flowParamName; flowIDElement .setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN);
public List<FilterMeta> populateFilterMetaData(FacesContext context, TreeTable tt) { List<FilterMeta> filterMetadata = new ArrayList<>(); String separator = String.valueOf(UINamingContainer.getSeparatorChar(context)); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); for (UIColumn column : tt.getColumns()) { ValueExpression columnFilterByVE = column.getValueExpression("filterBy"); if (columnFilterByVE != null) { UIComponent filterFacet = column.getFacet("filter"); ValueExpression filterByVE = columnFilterByVE; Object filterValue = null; String filterId = null; if (column instanceof Column) { filterId = column.getClientId(context) + separator + "filter"; filterValue = (filterFacet == null) ? params.get(filterId) : ((ValueHolder) filterFacet).getLocalValue(); } else if (column instanceof DynamicColumn) { DynamicColumn dynamicColumn = (DynamicColumn) column; dynamicColumn.applyModel(); filterId = dynamicColumn.getContainerClientId(context) + separator + "filter"; filterValue = (filterFacet == null) ? params.get(filterId) : ((ValueHolder) filterFacet).getLocalValue(); dynamicColumn.cleanModel(); } filterMetadata.add(new FilterMeta(column, filterByVE, filterValue)); } } return filterMetadata; }
@Override public void render(FacesContext context, Pageable pageable) throws IOException { String template = pageable.getRowsPerPageTemplate(); UIViewRoot viewroot = context.getViewRoot(); char separator = UINamingContainer.getSeparatorChar(context); ResponseWriter writer = context.getResponseWriter(); int actualRows = pageable.getRows(); String[] options = pageable.getRowsPerPageTemplate().split("[,]+"); String ddId = clientId + separator + viewroot.createUniqueId(); String ddName = clientId + "_rppDD"; String labelId = null; labelId = ddId + "_rppLabel"; writer.startElement("label", null); writer.writeAttribute("id", labelId, null); writer.writeAttribute("for", ddId, null); writer.writeAttribute("class", UIData.PAGINATOR_RPP_LABEL_CLASS, null); writer.writeText(label, null);
protected void encodeOption(FacesContext context, SelectCheckboxMenu menu, Object values, Object submittedValues, Converter converter, SelectItem option, int idx, String selectItemGroupLabel) throws IOException { ResponseWriter writer = context.getResponseWriter(); String itemValueAsString = getOptionAsString(context, menu, converter, option.getValue()); String name = menu.getClientId(context); String id = name + UINamingContainer.getSeparatorChar(context) + idx; boolean disabled = option.isDisabled() || menu.isDisabled(); boolean escaped = option.isEscape(); writer.startElement("input", null); writer.writeAttribute("id", id, null); writer.writeAttribute("name", name, null); writer.writeAttribute("type", "checkbox", null); writer.writeAttribute("value", itemValueAsString, null);
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { String ccID = (String) component.getAttributes().get(COMP_KEY); if (null != ccID) { char sep = UINamingContainer.getSeparatorChar(context); UIComponent cc; // If the composite component id includes the separator char... if (-1 != ccID.indexOf(sep)) { // use the UIViewRoot's findComponent. cc = context.getViewRoot().findComponent(':' + ccID); } else { // ... otherwise use our special findComponent. cc = findComponentIgnoringNamingContainers(context.getViewRoot(), ccID, true); } UIComponent curCC = UIComponent.getCurrentCompositeComponent(context); if (cc != curCC) { // the first pop maps to the component we're rendering. // push the composite component to the 'stack' and then re-push // the component we're rendering so the current component is // correct. component.popComponentFromEL(context); component.pushComponentToEL(context, cc); component.pushComponentToEL(context, component); } } }
@Override public void decode(FacesContext facesContext, UIComponent uiComponent) { ExternalContext externalContext = facesContext.getExternalContext(); Map<String, String> requestParameterMap = externalContext.getRequestParameterMap(); String clientId = uiComponent.getClientId(); char separatorChar = UINamingContainer.getSeparatorChar(facesContext); String escapedEditorName = clientId.replace(separatorChar, '_').concat("_jsptag"); String submittedValue = requestParameterMap.get(escapedEditorName + "_bbcodeInput"); if (submittedValue == null) { submittedValue = requestParameterMap.get(escapedEditorName); } InputRichText inputRichText = (InputRichText) uiComponent; inputRichText.setSubmittedValue(submittedValue); }
public String findComponentsClientId(final String id) { if (id.contains(UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance())+"")) { // we assume that client id is correct return id; } final UIComponent component = findComponent(id); return component != null ? component.getClientId() : id; }
private static String getResolvedId(UIComponent component, String id) { UIComponent resolvedComponent = component.findComponent(id); if (resolvedComponent == null) { if (id.charAt(0) == UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance())) { return id.substring(1); } return id; } return resolvedComponent.getClientId(); } }
public static String getClientWindowId(FacesContext context) { String result = null; final String clientWindowIdCounterKey = "com.sun.faces.util.ClientWindowCounterKey"; Map<Object, Object> contextAttrs = context.getAttributes(); Integer counter = (Integer) contextAttrs.get(clientWindowIdCounterKey); if (null == counter) { counter = Integer.valueOf(0); } char sep = UINamingContainer.getSeparatorChar(context); result = context.getViewRoot().getContainerClientId(context) + sep + ResponseStateManager.CLIENT_WINDOW_PARAM + sep + counter; contextAttrs.put(clientWindowIdCounterKey, ++counter); return result; }
FacesContext context = FacesContext.getCurrentInstance(); PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(context); try { UIViewRoot viewRoot = context.getViewRoot(); if (viewRoot != null) { String parameterNamespace = viewRoot.getContainerClientId(context); if ((parameterNamespace != null) && (parameterNamespace.length() > 0)) { parameterPrefix += UINamingContainer.getSeparatorChar(context); if (context.isPostback() && !context.getPartialViewContext().isRenderAll() && !applicationContext.getEnvironment().isAtLeastJsf23()) { updateStarted = true; resourceInfo.getResource().encodeAll(context);
@Override public String getFor() { String forComponentId = super.getFor(); if (forComponentId == null) { java.util.logging.Logger.getLogger(this.getClass().getName()).warning("Required attribute 'for' is null in ace:tabSetProxy component with id "+getId()+" in view "+FacesContext.getCurrentInstance().getViewRoot().getViewId()+"."); return ""; } FacesContext facesContext = getFacesContext(); UIViewRoot root = facesContext.getViewRoot(); String separator = String.valueOf(UINamingContainer.getSeparatorChar(facesContext)); if (forComponentId.contains(separator)) { UIComponent forComponent = CoreComponentUtils.findComponentInView(root, forComponentId); if (forComponent == null) { return forComponentId; } else { return forComponent.getClientId(); } } else { return forComponentId; } }
@Override public void encode(FacesContext context, DataTableRenderer renderer, DataTable table) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); String globalFilterValue = null; String globalFilterParam = clientId + UINamingContainer.getSeparatorChar(context) + "globalFilter"; globalFilterValue = params.get(globalFilterParam); filter(context, table, table.getFilterMetadata(), globalFilterValue); context.getApplication().publishEvent(context, PostFilterEvent.class, table);
UIViewRoot viewRoot = context.getViewRoot(); id = viewRoot.createUniqueId(); String containerClientId = namingContainer.getContainerClientId(context); clientId = sb.append(containerClientId).append(UINamingContainer.getSeparatorChar(context)).append(id).toString();
@Override public void decode(FacesContext context, UIComponent component) { Map<String,String> params = context.getExternalContext().getRequestParameterMap(); RowEditor editor = (RowEditor) component; String clientId = editor.getClientId(context); //Decode row edit request triggered by this editor if(params.containsKey(clientId)) { DataTable table = findParentTable(context, editor); RowState state = (RowState)(context.getExternalContext().getRequestMap().get(table.getRowStateVar())); String tableId = table.getClientId(context); tableId = tableId.substring(0, tableId.lastIndexOf(UINamingContainer.getSeparatorChar(context))); if (params.containsKey(tableId + "_editSubmit")) { component.queueEvent(new RowEditEvent(component, table.getRowData())); if (table.isToggleOnInvalidEdit()) { for (Column c : table.getColumns()) state.removeActiveCellEditor(c.getCellEditor()); } } else if (params.containsKey(tableId + "_editCancel")) { component.queueEvent(new RowEditCancelEvent(component, table.getRowData())); for (Column c : table.getColumns()) { CellEditor ce = c.getCellEditor(); if (ce != null) revertInputs(ce.getFacet("input")); } for (Column c : table.getColumns()) state.removeActiveCellEditor(c.getCellEditor()); } } }
@Override public void encodeBegin(final FacesContext context) throws IOException { // HDIV parameter name HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String hdivParameter = HDIVUtil.getRequestContext(request).getHdivParameterName(); String name = getName(); if (name != null && name.equals(hdivParameter)) { // It is the Hdiv parameter added automatically by the link, so do nothing } else { UIComponent parent = getParent(); String parentClientId = parent.getClientId(context); // It is a parameter added by the application, so store its value in the JSF state to be able to validate it in future requests. Object val = getValue(); StateManager stateManager = getStateManager(context); if (stateManager != null) { String id = parentClientId + UINamingContainer.getSeparatorChar(context) + name; stateManager.saveState(id, val); } } super.encodeBegin(context); }
private String calculateClientWindow(FacesContext context) { synchronized(context.getExternalContext().getSession(true)) { final String clientWindowCounterKey = "com.sun.faces.lifecycle.ClientWindowCounterKey"; ExternalContext extContext = context.getExternalContext(); Map<String, Object> sessionAttrs = extContext.getSessionMap(); Integer counter = (Integer) sessionAttrs.get(clientWindowCounterKey); if (null == counter) { counter = Integer.valueOf(0); } char sep = UINamingContainer.getSeparatorChar(context); id = extContext.getSessionId(true) + sep + + counter; sessionAttrs.put(clientWindowCounterKey, ++counter); } return id; }