HtmlOutputLabel hol = new HtmlOutputLabel(); hol.setValue("label"); hol.setStyleClass("label"); tab.getChildren().add(hol);
@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; }
/** * Build a label. * * @param property * The property. May not be null. * @param context * The jsf context. May not be null. */ public final void buildLabel(final PresentationPropertyDescriptor<?, ?> property, final RenderContext context) { Validate.notNull(property, AbstractRenderStrategy.PROPERTY_NULL); Validate.notNull(context, AbstractRenderStrategy.CONTEXT_NULL); this.label = new HtmlOutputLabel(); this.label.setId(this.createLabelName(context)); this.label.setFor(this.createInputName(context)); final StringBuilder builder = new StringBuilder(); builder.append(property.getDescription(context.getFacesContext().getViewRoot().getLocale())); if (property.isRequiredIndication()) { builder.append("*"); } builder.append(AbstractRenderStrategy.SEPARATOR); this.label.setValue(builder.toString()); this.label.setStyleClass(context.resolveStyleClass(JsfStyleClasses.FORM_OUTPUT_LABEL)); }
/** * 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)); }
/** * Build a label. * * @param property * The property. May not be null. * @param context * The jsf context. May not be null. */ public final void buildLabel(final PropertyDescriptor<?, ?> property, final RenderContext context) { Validate.notNull(property, AbstractRenderStrategy.PROPERTY_NULL); Validate.notNull(context, AbstractRenderStrategy.CONTEXT_NULL); this.label = new HtmlOutputLabel(); this.label.setId(this.createLabelName(context)); this.label.setFor(this.createInputName(context)); String labelValue = property.getName(); if (property.adaptable(PresentationPropertyDescriptor.class)) { @SuppressWarnings("unchecked") final PresentationPropertyDescriptor<P, E> descriptor = property.adapt(PresentationPropertyDescriptor.class); labelValue = descriptor.getDescription(context.getFacesContext().getViewRoot().getLocale()); } final StringBuilder builder = new StringBuilder(); builder.append(labelValue); builder.append(AbstractRenderStrategy.SEPARATOR); this.label.setValue(builder.toString()); this.label.setStyleClass(context.resolveStyleClass(JsfStyleClasses.FORM_OUTPUT_LABEL)); }
/** * Build the label. * * @param property * The property. * @param context * The render context. */ public void buildLabel(final PropertyDescriptor<?, ?> property, final RenderContext context) { property.getName(); this.label = new HtmlOutputLabel(); this.label.setId(this.compileLabelName(context.getPrefixDeque())); this.label.setFor(this.compileInputName(context.getPrefixDeque())); String labelValue = property.getName(); if (property.adaptable(PresentationPropertyDescriptor.class)) { @SuppressWarnings("unchecked") final PresentationPropertyDescriptor<P, E> descriptor = property.adapt(PresentationPropertyDescriptor.class); labelValue = descriptor.getDescription(context.getFacesContext().getViewRoot().getLocale()); } final StringBuilder builder = new StringBuilder(); builder.append(labelValue); builder.append(DefaultReadOnlyOutput.LABEL_SEPARATOR); this.label.setValue(builder.toString()); this.label.setStyleClass(context.resolveStyleClass(JsfStyleClasses.FORM_OUTPUT_LABEL)); }