private void doSetBindings(ELContext elContext, UIComponent component) { if (component == null) return; ValueExpression binding = component.getValueExpression("binding"); if (binding != null) binding.setValue(elContext, component); Iterator<UIComponent> iter = component.getFacetsAndChildren(); while (iter.hasNext()) doSetBindings(elContext, iter.next()); }
/** Decodes the data from the form. */ @Override public void decode(FacesContext context, UIComponent component) { String clientId = component.getClientId(context); ExternalContext ext = context.getExternalContext(); Map<String, String> paramMap = ext.getRequestParameterMap(); String value = paramMap.get(clientId); if (value != null) ((EditableValueHolder) component).setSubmittedValue(value); }
protected void setProperties(UIComponent component) { super.setProperties(component); javax.faces.component.UISelectOne selectone = null; try { selectone = (javax.faces.component.UISelectOne) component; } catch (ClassCastException cce) { throw new IllegalStateException( "Component " + component.toString() + " not expected type. Expected: javax.faces.component.UISelectOne. Perhaps you're missing a tag?"); } if (converter != null) { if (!converter.isLiteralText()) { selectone.setValueExpression("converter", converter); } else { Converter conv = FacesContext.getCurrentInstance() .getApplication() .createConverter(converter.getExpressionString()); selectone.setConverter(conv); } } if (converterMessage != null) { selectone.setValueExpression("converterMessage", converterMessage); } if (immediate != null) { selectone.setValueExpression("immediate", immediate); } if (required != null) { selectone.setValueExpression("required", required); } if (requiredMessage != null) { selectone.setValueExpression("requiredMessage", requiredMessage); } if (validator != null) { selectone.addValidator(new MethodExpressionValidator(validator)); } if (validatorMessage != null) { selectone.setValueExpression("validatorMessage", validatorMessage); } if (value != null) { selectone.setValueExpression("value", value); } if (valueChangeListener != null) { selectone.addValueChangeListener( new MethodExpressionValueChangeListener(valueChangeListener)); } if (accesskey != null) { selectone.setValueExpression("accesskey", accesskey); } if (dir != null) { selectone.setValueExpression("dir", dir); } if (disabled != null) { selectone.setValueExpression("disabled", disabled); } if (disabledClass != null) { selectone.setValueExpression("disabledClass", disabledClass); } if (enabledClass != null) { selectone.setValueExpression("enabledClass", enabledClass); } if (label != null) { selectone.setValueExpression("label", label); } if (lang != null) { selectone.setValueExpression("lang", lang); } if (onblur != null) { selectone.setValueExpression("onblur", onblur); } if (onchange != null) { selectone.setValueExpression("onchange", onchange); } if (onclick != null) { selectone.setValueExpression("onclick", onclick); } if (ondblclick != null) { selectone.setValueExpression("ondblclick", ondblclick); } if (onfocus != null) { selectone.setValueExpression("onfocus", onfocus); } if (onkeydown != null) { selectone.setValueExpression("onkeydown", onkeydown); } if (onkeypress != null) { selectone.setValueExpression("onkeypress", onkeypress); } if (onkeyup != null) { selectone.setValueExpression("onkeyup", onkeyup); } if (onmousedown != null) { selectone.setValueExpression("onmousedown", onmousedown); } if (onmousemove != null) { selectone.setValueExpression("onmousemove", onmousemove); } if (onmouseout != null) { selectone.setValueExpression("onmouseout", onmouseout); } if (onmouseover != null) { selectone.setValueExpression("onmouseover", onmouseover); } if (onmouseup != null) { selectone.setValueExpression("onmouseup", onmouseup); } if (onselect != null) { selectone.setValueExpression("onselect", onselect); } if (readonly != null) { selectone.setValueExpression("readonly", readonly); } if (style != null) { selectone.setValueExpression("style", style); } if (styleClass != null) { selectone.setValueExpression("styleClass", styleClass); } if (tabindex != null) { selectone.setValueExpression("tabindex", tabindex); } if (title != null) { selectone.setValueExpression("title", title); } }
/** Renders the open tag for the text. */ @Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter out = context.getResponseWriter(); String id = component.getId(); String accesskey; String dir; boolean disabled; String disabledClass; String enabledClass; String lang; String onblur; String onchange; String onclick; String ondblclick; String onfocus; String onkeydown; String onkeypress; String onkeyup; String onmousedown; String onmousemove; String onmouseout; String onmouseover; String onmouseup; String onselect; boolean readonly; String style; String styleClass; String tabindex; String title; Object value; if (component instanceof HtmlSelectOneMenu) { HtmlSelectOneMenu htmlComponent = (HtmlSelectOneMenu) component; accesskey = htmlComponent.getAccesskey(); dir = htmlComponent.getDir(); disabled = htmlComponent.isDisabled(); disabledClass = htmlComponent.getDisabledClass(); enabledClass = htmlComponent.getEnabledClass(); lang = htmlComponent.getLang(); onblur = htmlComponent.getOnblur(); onchange = htmlComponent.getOnchange(); onclick = htmlComponent.getOnclick(); ondblclick = htmlComponent.getOndblclick(); onfocus = htmlComponent.getOnfocus(); onkeydown = htmlComponent.getOnkeydown(); onkeypress = htmlComponent.getOnkeypress(); onkeyup = htmlComponent.getOnkeyup(); onmousedown = htmlComponent.getOnmousedown(); onmousemove = htmlComponent.getOnmousemove(); onmouseout = htmlComponent.getOnmouseout(); onmouseover = htmlComponent.getOnmouseover(); onmouseup = htmlComponent.getOnmouseup(); onselect = htmlComponent.getOnselect(); readonly = htmlComponent.isReadonly(); style = htmlComponent.getStyle(); styleClass = htmlComponent.getStyleClass(); tabindex = htmlComponent.getTabindex(); title = htmlComponent.getTitle(); value = htmlComponent.getValue(); } else { Map<String, Object> attrMap = component.getAttributes(); accesskey = (String) attrMap.get("accesskey"); dir = (String) attrMap.get("dir"); disabled = Boolean.TRUE.equals(attrMap.get("disabled")); disabledClass = (String) attrMap.get("disabledClass"); enabledClass = (String) attrMap.get("enabledClass"); lang = (String) attrMap.get("lang"); onblur = (String) attrMap.get("onblur"); onchange = (String) attrMap.get("onchange"); onclick = (String) attrMap.get("onclick"); ondblclick = (String) attrMap.get("ondblclick"); onfocus = (String) attrMap.get("onfocus"); onkeydown = (String) attrMap.get("onkeydown"); onkeypress = (String) attrMap.get("onkeypress"); onkeyup = (String) attrMap.get("onkeyup"); onmousedown = (String) attrMap.get("onmousedown"); onmousemove = (String) attrMap.get("onmousemove"); onmouseout = (String) attrMap.get("onmouseout"); onmouseover = (String) attrMap.get("onmouseover"); onmouseup = (String) attrMap.get("onmouseup"); onselect = (String) attrMap.get("onselect"); readonly = Boolean.TRUE.equals(attrMap.get("readonly")); style = (String) attrMap.get("style"); styleClass = (String) attrMap.get("styleClass"); tabindex = (String) attrMap.get("tabindex"); title = (String) attrMap.get("title"); value = attrMap.get("value"); } UIViewRoot viewRoot = context.getViewRoot(); out.startElement("select", component); if (style != null) out.writeAttribute("style", style, "style"); if (styleClass != null) out.writeAttribute("class", styleClass, "class"); String clientId = component.getClientId(context); out.writeAttribute("name", clientId, "name"); if (id != null && !id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) out.writeAttribute("id", clientId, "id"); if (disabled) out.writeAttribute("disabled", "disabled", "disabled"); if (accesskey != null) out.writeAttribute("accesskey", accesskey, "accesskey"); if (dir != null) out.writeAttribute("dir", dir, "dir"); if (lang != null) out.writeAttribute("lang", lang, "lang"); if (onblur != null) out.writeAttribute("onblur", onblur, "onblur"); if (onchange != null) out.writeAttribute("onchange", onchange, "onchange"); if (onclick != null) out.writeAttribute("onclick", onclick, "onclick"); if (ondblclick != null) out.writeAttribute("ondblclick", ondblclick, "ondblclick"); if (onfocus != null) out.writeAttribute("onfocus", onfocus, "onfocus"); if (onkeydown != null) out.writeAttribute("onkeydown", onkeydown, "onkeydown"); if (onkeypress != null) out.writeAttribute("onkeypress", onkeypress, "onkeypress"); if (onkeyup != null) out.writeAttribute("onkeyup", onkeyup, "onkeyup"); if (onmousedown != null) out.writeAttribute("onmousedown", onmousedown, "onmousedown"); if (onmousemove != null) out.writeAttribute("onmousemove", onmousemove, "onmousemove"); if (onmouseout != null) out.writeAttribute("onmouseout", onmouseout, "onmouseout"); if (onmouseover != null) out.writeAttribute("onmouseover", onmouseover, "onmouseover"); if (onmouseup != null) out.writeAttribute("onmouseup", onmouseup, "onmouseup"); if (onselect != null) out.writeAttribute("onselect", onselect, "onselect"); if (readonly) out.writeAttribute("readonly", "readonly", "readonly"); if (tabindex != null) out.writeAttribute("tabindex", tabindex, "tabindex"); if (title != null) out.writeAttribute("title", title, "title"); out.writeAttribute("size", "1", "size"); out.write("\n"); encodeOneChildren(out, context, component, value, enabledClass, disabledClass); out.endElement("select"); out.write("\n"); for (UIComponent child : component.getChildren()) { if (child instanceof UIComponent) child.encodeAll(context); } }
private void printComponentTree( PrintWriter out, String errorId, FacesContext context, UIComponent comp, int depth) { for (int i = 0; i < depth; i++) out.print(' '); boolean isError = false; if (errorId != null && errorId.equals(comp.getClientId(context))) { isError = true; out.print("<span style='color:red'>"); } out.print("<" + comp.getClass().getSimpleName()); if (comp.getId() != null) out.print(" id=\"" + comp.getId() + "\""); for (Method method : comp.getClass().getMethods()) { if (!method.getName().startsWith("get") && !method.getName().startsWith("is")) continue; else if (method.getParameterTypes().length != 0) continue; String name; if (method.getName().startsWith("get")) name = method.getName().substring(3); else if (method.getName().startsWith("is")) name = method.getName().substring(2); else continue; // XXX: getURL name = Character.toLowerCase(name.charAt(0)) + name.substring(1); ValueExpression expr = comp.getValueExpression(name); Class type = method.getReturnType(); if (expr != null) { out.print(" " + name + "=\"" + expr.getExpressionString() + "\""); } else if (method.getDeclaringClass().equals(UIComponent.class) || method.getDeclaringClass().equals(UIComponentBase.class)) { } else if (name.equals("family")) { } else if (String.class.equals(type)) { try { Object value = method.invoke(comp); if (value != null) out.print(" " + name + "=\"" + value + "\""); } catch (Exception e) { } } } int facetCount = comp.getFacetCount(); int childCount = comp.getChildCount(); if (facetCount == 0 && childCount == 0) { out.print("/>"); if (isError) out.print("</span>"); out.println(); return; } out.println(">"); if (isError) out.print("</span>"); for (int i = 0; i < childCount; i++) { printComponentTree(out, errorId, context, comp.getChildren().get(i), depth + 1); } for (int i = 0; i < depth; i++) out.print(' '); if (isError) out.print("<span style='color:red'>"); out.println("</" + comp.getClass().getSimpleName() + ">"); if (isError) out.print("</span>"); }
public static String getLabel(FacesContext context, UIComponent component) { String label = (String) component.getAttributes().get("label"); if (label != null && !"".equals(label)) return label; else return component.getClientId(context); }