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); } }
/** * 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)); }
/** * 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; }
/** * 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)); }
/** * 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; }