public HtmlOutputLabel() { super(); setRendererType("javax.faces.Label"); }
HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue"); ValueExpression vb = ob.getValueExpression("value"); Object value = vb.getValue(FacesContext.getCurrentInstance().getELContext());
/** * <p>Set the value of the <code>accesskey</code> property.</p> * @param accesskey the new property value */ public void setAccesskey(java.lang.String accesskey) { getStateHelper().put(PropertyKeys.accesskey, accesskey); handleAttribute("accesskey", accesskey); }
HtmlOutputLabel hol = new HtmlOutputLabel(); hol.setValue("label"); hol.setStyleClass("label"); tab.getChildren().add(hol);
private void createLabel() { if (isShowLabel()) { labelUser = new HtmlOutputLabel(); StringBuilder idGenerate = new StringBuilder(); idGenerate.append(getId()).append('-').append("label"); labelUser.setId(idGenerate.toString()); labelUser.setFor(inputUser.getId()); StringBuilder value = new StringBuilder(); value.append(getValue()).append(" :"); if (isRequired()) { value.append("*"); } labelUser.setValue(value.toString()); this.getChildren().add(labelUser); } }
private void handleAttribute(String name, Object value) { List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet"); if (setAttributes == null) { String cname = this.getClass().getName(); if (cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) { setAttributes = new ArrayList<String>(6); this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes); } } if (setAttributes != null) { if (value == null) { ValueExpression ve = getValueExpression(name); if (ve == null) { setAttributes.remove(name); } } else if (!setAttributes.contains(name)) { setAttributes.add(name); } } }
/** * Gets Script to be invoked when the element is clicked. * * @return the new onclick value */ public String getOnclick() { if (_onclick != null) { return _onclick; } ValueExpression expression = getValueExpression("onclick"); if (expression != null) { return (String)expression.getValue(getFacesContext().getELContext()); } return null; }
/** * Create a label component for the given <code>UIComponent</code>. Clients may override this * method to create a different type of label component. */ protected UIOutput createLabel( FacesContext context, UIComponent componentNeedingLabel ) { HtmlOutputLabel componentLabel = (HtmlOutputLabel) context.getApplication().createComponent( HtmlOutputLabel.COMPONENT_TYPE ); if ( componentNeedingLabel instanceof UIStub ) { // Not setFor on UIStub, because stubs never render id. However we can take a guess if // there's only one child component if ( componentNeedingLabel.getChildren().size() == 1 ) { componentLabel.setFor( componentNeedingLabel.getChildren().get( 0 ).getId() ); } } else if ( componentNeedingLabel.getId() != null ) { componentLabel.setFor( componentNeedingLabel.getId() ); } // Call .setParent before .setId to avoid 'unable to find component with id' warning and/or // 'duplicate component' error (depending on the JSF implementation) if ( componentLabel.getFor() != null ) { componentLabel.setParent( componentNeedingLabel.getParent() ); componentLabel.setId( componentLabel.getFor() + LABEL_ID_SUFFIX ); } return componentLabel; }
UIComponent maybe = children.get(j); if (maybe instanceof HtmlOutputLabel) { if (kid.getId().equals(((HtmlOutputLabel) maybe).getFor())) { needsLabel = false; label.getPassThroughAttributes().put("for", kid.getClientId()); kid.getAttributes().put("renderLabel", false); label.setFor(kid.getId()); if (null != caption) { String translationParam = FacesContext.getCurrentInstance().getExternalContext() if (null == translationParam || "true".equalsIgnoreCase(translationParam)) { label.setValue(translate(caption)); } else { label.setValue(caption);
protected String getFor(UIComponent component) { if (component instanceof HtmlOutputLabel) { return ((HtmlOutputLabel)component).getFor(); } return (String)component.getAttributes().get(JSFAttr.FOR_ATTR); }
/** * <p>Return the value of the <code>onfocus</code> property.</p> * @return the property value * <p>Contents: Javascript code executed when this element receives focus. */ public java.lang.String getOnfocus() { return (java.lang.String) getStateHelper().eval(PropertyKeys.onfocus); }
@NotNull public static HtmlOutputLabel addLabel(@NotNull UIComponent parent, FacesComponentIdFactory idFactory, UIInput associatedInput, String value, String styleClass) { HtmlOutputLabel label = createComponent(HtmlOutputLabel.class, idFactory); label.setFor(associatedInput.getId()); label.setValue(value); label.setStyleClass(styleClass); parent.getChildren().add(label); return label; }
comp.setValueExpression("for", _for); comp.setValueExpression("accesskey", _accesskey); comp.setValueExpression("escape", _escape); comp.setValueExpression("onclick", _onclick); comp.setValueExpression("ondblclick", _ondblclick); comp.setValueExpression("onkeydown", _onkeydown); comp.setValueExpression("onkeypress", _onkeypress); comp.setValueExpression("onkeyup", _onkeyup); comp.setValueExpression("onmousedown", _onmousedown); comp.setValueExpression("onmousemove", _onmousemove); comp.setValueExpression("onmouseout", _onmouseout); comp.setValueExpression("onmouseover", _onmouseover); comp.setValueExpression("onmouseup", _onmouseup); comp.setValueExpression("style", _style); comp.setValueExpression("styleClass", _styleClass);
panel.setColumns(2); HtmlOutputLabel labelUser = new HtmlOutputLabel(); labelUser.setFor(USER_NAME); labelUser.setValue(Utils.getMessageResourceString(SecurityConst.BUNDLE_NAME, SecurityConst.USER_LOGIN, null, null)); HtmlOutputLabel labelPwd = new HtmlOutputLabel(); labelPwd.setFor(PWD_NAME); labelPwd.setValue(Utils.getMessageResourceString(SecurityConst.BUNDLE_NAME, SecurityConst.PWD_LOGIN, null, null)); panel.getChildren().add(labelPwd);
comp.setValueBinding("for", vb); comp.getAttributes().put("for", _for); comp.setValueBinding("style", vb); comp.getAttributes().put("style", _style); comp.setValueBinding("styleClass", vb); comp.getAttributes().put("styleClass", _styleClass); comp.setValueBinding("tabindex", vb); comp.getAttributes().put("tabindex", _tabindex); comp.setValueBinding("onblur", vb); comp.getAttributes().put("onblur", _onblur); comp.setValueBinding("onfocus", vb); comp.getAttributes().put("onfocus", _onfocus); comp.setValueBinding("accesskey", vb); comp.getAttributes().put("accesskey", _accesskey); comp.setValueBinding("onclick", vb);
private static void writeContent(List<String> row, StringListResponseWriter writer, FacesContext facesContext, int columnCount, UIComponent child) throws IOException { if (child instanceof HtmlCommandLink) { final HtmlOutputLabel label = new HtmlOutputLabel(); label.setValue(((HtmlCommandLink) child).getValue()); label.setRendered(child.isRendered()); label.encodeBegin(facesContext); label.encodeEnd(facesContext); } else if (child instanceof HtmlGraphicImage) { writer.writeText("", ""); //} else if (child instanceof UIInstructions) { // child.encodeBegin(facesContext); // child.encodeEnd(facesContext); // postCleanUp(row, columnCount); } else if (child instanceof HtmlPanelGroup || child instanceof HtmlOutputLink) { final UIComponentBase uiComponent = (UIComponentBase) child; if (uiComponent.isRendered()) { for (UIComponent uiChildComponent : uiComponent.getChildren()) { writeContent(row, writer, facesContext, columnCount, uiChildComponent); } } postCleanUp(row, columnCount); } else { child.encodeBegin(facesContext); child.encodeEnd(facesContext); } }
protected void encodeHtmlOutputLabelBegin(final FacesContext context, final HtmlOutputLabel htmlOutputLabel) throws IOException { final ResponseWriter writer = context.getResponseWriter(); writer.startElement(JsfConstants.LABEL_ELEM, htmlOutputLabel); RendererUtil.renderIdAttributeIfNecessary(writer, htmlOutputLabel, getIdForRender(context, htmlOutputLabel)); final String forAttr = htmlOutputLabel.getFor(); if (forAttr != null) { final UIComponent forComponent = htmlOutputLabel .findComponent(forAttr); if (forComponent == null) { throw new IllegalStateException("for Component [" + forAttr + "] does not found"); } final String forClientId = getIdForRender(context, forComponent); RendererUtil.renderAttribute(writer, JsfConstants.FOR_ATTR, forClientId, null); } renderRemainAttributes(htmlOutputLabel, writer, ignoreComponent); final String value = ValueHolderUtil.getValueForRender(context, htmlOutputLabel); writer.writeText(value, null); }
/** * Build the label. * * @param property * The property. * @param context * The render context. * @param locale * The locale. */ public void buildLabel(final PresentationPropertyDescriptor<?, ?> property, final RenderContext context, final Locale locale) { this.label = new HtmlOutputLabel(); this.label.setId(this.compileLabelName(context.getPrefixDeque())); this.label.setFor(this.compileInputName(context.getPrefixDeque())); final StringBuilder builder = new StringBuilder(); builder.append(property.getDescription(locale)); builder.append(DefaultReadOnlyOutput.LABEL_SEPARATOR); this.label.setValue(builder.toString()); this.label.setStyleClass(context.resolveStyleClass(JsfStyleClasses.FORM_OUTPUT_LABEL)); }
private void handleAttribute(String name, Object value) { List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet"); if (setAttributes == null) { String cname = this.getClass().getName(); if (cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) { setAttributes = new ArrayList<String>(6); this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes); } } if (setAttributes != null) { if (value == null) { ValueExpression ve = getValueExpression(name); if (ve == null) { setAttributes.remove(name); } } else if (!setAttributes.contains(name)) { setAttributes.add(name); } } }