in empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java [1549:1645]
public HtmlOutputLabel createLabelComponent(FacesContext context, String forInput, String styleClass, String style, boolean colon)
{
Column column = null;
boolean readOnly=false;
boolean required=false;
// forInput provided
if (StringUtils.isNotEmpty(forInput))
{ // find the component
if (!forInput.equals("*"))
{ // Set Label input Id
UIComponent input = FacesUtils.getWebApplication().findComponent(context, forInput, component);
if (input!=null && (input instanceof InputTag))
{ // Check Read-Only
InputTag inputTag = ((InputTag)input);
column = inputTag.getInputColumn();
readOnly = inputTag.isInputReadOnly();
required = inputTag.isInputRequired();
}
else
{ // Not found (<e:input id="ABC"...> must match <e:label for="ABC"...>
log.warn("Input component {} not found for label {}.", forInput, getColumn().getName());
}
}
else if (component instanceof LabelTag)
{ // for LabelTag
forInput = this.getColumnName();
// readOnly
Object val = getAttributeValueEx("readOnly");
if (val!=null)
readOnly = ObjectUtils.getBoolean(val);
else
readOnly = this.isReadOnly();
}
else
{ // for ControlTag
readOnly = this.isReadOnly();
}
}
// Column provided?
if (column==null)
{ // Get from LinkTag
column = getColumn();
required = !readOnly && isValueRequired(); // does only check Attribute
}
// Check column
if (column==null)
throw new InvalidArgumentException("column", column);
// create label now
HtmlOutputLabel label = InputControlManager.createComponent(context, InputControlManager.getLabelComponentClass());
// value
String labelText = getLabelValue(column, colon);
if (StringUtils.isEmpty(labelText))
label.setRendered(false);
else
label.setValue(labelText);
// styleClass
if (StringUtils.isNotEmpty(styleClass))
label.setStyleClass(completeLabelStyleClass(styleClass, required));
// for
if (StringUtils.isNotEmpty(forInput) && !readOnly)
{ // Set Label input Id
InputControl.InputInfo ii = getInputInfo(context);
String inputId = getInputControl().getLabelForId(ii);
if (StringUtils.isNotEmpty(inputId))
{ // input_id was given
if (forInput.equals("*"))
label.setFor(inputId);
else
label.setFor(forInput+":"+inputId);
}
else
{ // No input-id available
log.info("No input-id provided for {}.", getColumn().getName());
}
}
// style
if (StringUtils.isNotEmpty(style))
label.setStyle(style);
// title
String title = getLabelTooltip(column);
if (title!=null)
label.setTitle(title);
// required
if (required && InputControlManager.isShowLabelRequiredMark())
addRequiredMark(label);
return label;
}