public static Object getLabel(FacesContext facesContext, UIComponent component) { String label = (String) component.getAttributes().get("label"); if (label == null) { label = component.getClientId(facesContext); } return label; }
public static ResourceInfo newResourceInfo(UIComponent component) { if (!(component instanceof UIOutput)) { return null; } String library = (String) component.getAttributes().get("library"); String name = (String) component.getAttributes().get("name"); return new ResourceInfo(library, name, component); }
protected void addAttachedObjectHandlerToMojarra(PrimeEnvironment environment, UIComponent component) { String key = MOJARRA_ATTACHED_OBJECT_HANDLERS_KEY; if (environment.isAtLeastJsf22()) { key = MOJARRA_22_ATTACHED_OBJECT_HANDLERS_KEY; } Map<String, Object> attrs = component.getAttributes(); List<AttachedObjectHandler> result = (List<AttachedObjectHandler>) attrs.get(key); if (result == null) { result = new ArrayList<>(); attrs.put(key, result); } result.add(this); }
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = component.getClientId(context); writer.startElement("body", component); if (shouldWriteId(component)) { writer.writeAttribute("id", clientId, "id"); } String styleClass = (String) component.getAttributes().get("styleClass"); if (styleClass != null && styleClass.length() != 0) { writer.writeAttribute("class", styleClass, "styleClass"); } renderPassThruAttributes(context, component, HTML.BODY_ATTRS); }
protected String buildNonAjaxRequest(FacesContext context, UIComponent component, UIComponent form, String decodeParam, boolean submit) { StringBuilder request = SharedStringBuilder.get(context, SB_BUILD_NON_AJAX_REQUEST); String formId = form.getClientId(context); Map<String, Object> params = new HashMap<>(); params.put(decodeParam, decodeParam); UIParameter param = (UIParameter) child; params.put(param.getName(), param.getValue()); String value = EscapeUtils.forJavaScript(String.valueOf(params.get(key))) ; Object target = component.getAttributes().get("target"); request.append(".submit('").append(formId).append("'");
public void encodeChildren(FacesContext context, UIComponent component) throws IOException { // If the link has no children, render out the "value" as text. ResponseWriter writer = context.getResponseWriter(); String valueAttr = "value"; if (component.getAttributes().get(valueAttr) != null) { writer.writeText(component.getAttributes().get(valueAttr), valueAttr); } super.encodeChildren(context, component); }
public void doEncodeBegin(ResponseWriter writer, FacesContext context, javax.faces.component.UIComponent component, ComponentVariables variables ) throws IOException { writer.startElement("td", component); getUtils().writeAttribute(writer, "class", "dr-sdt-bc rich-sdt-column-cell " + convertToString(variables.getVariable("columnClass")) + " " + convertToString(variables.getVariable("columnSortClass")) + " " + convertToString(component.getAttributes().get("styleClass")) ); getUtils().writeAttribute(writer, "id", convertToString(variables.getVariable("client_id")) + ":c_" + convertToString(variables.getVariable("cell_id")) ); writer.startElement("div", component); getUtils().writeAttribute(writer, "class", "dr-sdt-cbody dr-sdt-c-" + convertToString(variables.getVariable("cell_index")) + " " + convertToString(component.getAttributes().get("cellClass")) ); getUtils().writeAttribute(writer, "id", convertToString(variables.getVariable("client_id")) + ":bc_" + convertToString(variables.getVariable("cell_id")) ); getUtils().writeAttribute(writer, "style", component.getAttributes().get("cellStyle") ); }
public static void addComponentResource(FacesContext context, String name, String library, String target) { Application application = context.getApplication(); UIComponent componentResource = application.createComponent(UIOutput.COMPONENT_TYPE); componentResource.setRendererType(application.getResourceHandler().getRendererTypeForResourceName(name)); componentResource.getAttributes().put("name", name); componentResource.getAttributes().put("library", library); componentResource.getAttributes().put("target", target); context.getViewRoot().addComponentResource(context, componentResource, target); }
public class ExtendedScriptRenderer extends ScriptRenderer { @Override protected void startElement(ResponseWriter writer, UIComponent component) throws IOException { writer.startElement("script", component); String type = (String) component.getAttributes().get("type"); if (type == null) type = "application/javascript"; writer.writeAttribute("type", type, "type"); } }
public static void markProperty(UIComponent component, long propertyConstant) { Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED); if (commonPropertiesSet == null) { commonPropertiesSet = 0L; } component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant); } }
protected void renderPassThruAttributes(FacesContext context, UIComponent component, String[] attrs) throws IOException { //pre-defined attributes if (attrs != null && attrs.length > 0) { ResponseWriter writer = context.getResponseWriter(); for (String attribute : attrs) { Object value = component.getAttributes().get(attribute); if (shouldRenderAttribute(value)) { writer.writeAttribute(attribute, value.toString(), attribute); } } } renderDynamicPassThruAttributes(context, component); }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException { String resourcePath = (String) component.getAttributes().get("path"); Assert.hasText(resourcePath, "Resource component " + component.getClientId(context) + " is missing a path."); if (!resourcePath.startsWith("/")) { resourcePath = "/" + resourcePath; component.getAttributes().put("path", resourcePath); } ResourceHelper.renderResource(context, resourcePath); }
public static String resolveWidgetVar(FacesContext context, Widget widget) { UIComponent component = (UIComponent) widget; String userWidgetVar = (String) component.getAttributes().get("widgetVar"); if (!LangUtils.isValueBlank(userWidgetVar)) { return userWidgetVar; } else { return "widget_" + component.getClientId(context).replaceAll("-|" + UINamingContainer.getSeparatorChar(context), "_"); } }
protected void renderPassThruAttributes(FacesContext facesContext, UIComponent component, String var, String[] attrs) throws IOException { ResponseWriter writer = facesContext.getResponseWriter(); for(String event : attrs) { String eventHandler = (String) component.getAttributes().get(event); if(eventHandler != null) writer.write(var + ".addListener(\"" + event.substring(2, event.length()) + "\", function(e){" + eventHandler + ";});\n"); } }
public void doEncodeBegin(ResponseWriter writer, FacesContext context, javax.faces.component.UIComponent component, ComponentVariables variables ) throws IOException { writer.startElement("div", component); getUtils().writeAttribute(writer, "class", "dr-sdt-cbody dr-sdt-c-" + convertToString(variables.getVariable("cell_index")) + " " + convertToString(component.getAttributes().get("headerClass")) ); getUtils().writeAttribute(writer, "id", convertToString(variables.getVariable("client_id")) + ":hcb_" + convertToString(variables.getVariable("cell_index")) ); }
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 (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().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); }
public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent) { StringBuffer content = new StringBuffer(); for (TextHandler handler : TagHandlerUtils.findNextByType(nextHandler, TextHandler.class)) { content.append(handler.getText(ctx)); } c.getAttributes().put("value", content.toString()); c.getAttributes().put("escape", Boolean.FALSE); c.setTransient(true); }
public static void markProperty(UIComponent component, long propertyConstant) { Long commonPropertiesSet = (Long) component.getAttributes().get(COMMON_PROPERTIES_MARKED); if (commonPropertiesSet == null) { commonPropertiesSet = 0L; } component.getAttributes().put(COMMON_PROPERTIES_MARKED, commonPropertiesSet | propertyConstant); } }
private void renderDomEvents(FacesContext context, UIComponent component, String[] eventAttrs, Map<String, List<ClientBehavior>> behaviors) throws IOException { ResponseWriter writer = context.getResponseWriter(); StringBuilder builder = null; Object eventValue = component.getAttributes().get(domEvent); String behaviorEvent = domEvent.substring(2, domEvent.length()); List<ClientBehavior> eventBehaviors = behaviors.get(behaviorEvent); boolean hasEventValue = (eventValue != null); boolean hasEventBehaviors = (eventBehaviors != null && !eventBehaviors.isEmpty()); eventBehaviors = behaviors.get("valueChange"); hasEventBehaviors = (eventBehaviors != null && !eventBehaviors.isEmpty()); if (hasEventBehaviors) { String clientId = component.getClientId(context); writer.writeAttribute(domEvent, builder.toString(), domEvent); builder.setLength(0);
private void updateClientFirst(FacesContext context, UIComponent component, String clientFirst) { if (clientFirst != null && clientFirst.length() > 0) { Integer value = Integer.valueOf(clientFirst); Map<String, Object> attributes = component.getAttributes(); if (!value.equals(attributes.get("clientFirst"))) { attributes.put(AbstractExtendedDataTable.SUBMITTED_CLIENT_FIRST, value); context.getPartialViewContext().getRenderIds() .add(component.getClientId(context) + "@" + AbstractExtendedDataTable.SCROLL); } } }