Label
jtp:label
Additional user feedback for missing field input can be provided without having to rely on client side validation.
Required are the to be validated field and a boolean to check if validation should take place.
< jtp:label validated="#{bean.boolean}" field="#{bean.entity.field" />
If the field is empty and validated true the label will be marked red, otherwise it will have default styling.
< jtp:label entity="JeeAttribute" code="demo" .... > entity and code are evaluated to corresponding revision entity and attribute. Appropriate translated text is applied, when corresponding revision entity and attributes are not defined it is evaluated to entityName:column name so that we can be later put in translation in revision.
<p:panel styleClass="jeesl-panel">
<f:facet name="header"><j:pHeader title="Examples (jtp)"/></f:facet>
<f:facet name="actions">
<j:svg type="jeeslSave" listener="#{outputLabelBean.validate()}" update="@form" />
</f:facet>
<j:inputGrid>
<jtp:label entity="JeeAttribute"/>
<h:outputText id="jtp-entity" value="entity"/>
<jtp:label entity="JeeAttribute" code="label"/>
<h:outputText id="jtp-entity-code" value="entity+code"/>
<jtp:label entity="JeeAttribute" code="label" ttd="true"/>
<h:outputText id="jtp-tooltip" value="Tooltip Description"/>
</j:inputGrid>
</p:panel>
<p:panel styleClass="jeesl-panel">
<f:facet name="header"><j:pHeader title="Examples (j)"/></f:facet>
<f:facet name="actions">
<j:svg type="jeeslSave" listener="#{outputLabelBean.validate()}" update="@form" />
</f:facet>
<j:inputGrid>
<j2:label entity="JeeAttribute"/>
<h:outputText id="j-entity" value="entity="JeeAttribute""/>
<j2:label entity="JeeUnknown"/>
<h:outputText id="j-fallback-debug" value="entity="JeeUnknown" (Fallback to debug)"/>
<j2:label entity="JeeAttribute" userLocaleCode="de"/>
<h:outputText id="j-fallback-default" value="entity="JeeAttribute" (Fallback to default)"/>
</j:inputGrid>
<p:separator/>
<j:inputGrid>
<j2:label entity="JeeAttribute" code="label"/>
<h:outputText id="j-label" value="entity="JeeAttribute" code="label""/>
<p:panel styleClass="jeesl-panel">
<f:facet name="header"><j:pHeader title="Tests"/></f:facet>
<f:facet name="actions">
<j:svg type="jeeslSave" listener="#{outputLabelBean.validate()}" update="@form" />
</f:facet>
<j:inputGrid>
<j2:label entity="JeeAttribute" code="label" mandatory="true" field="#{outputLabelBean.field}" validated="#{outputLabelBean.validated}"/>
<p:inputText value="#{outputLabelBean.field}"/>
<j2:label entity="JeeAttribute" code="label" iOptions="#{appLabelBean.locales}"/>
<h:outputText id="test-image-options" value="Image Options (for entity+code)"/>
<j2:label entity="JeeAttribute" code="label" url="test"/>
<h:outputText id="test-entity-code" value="entity+code+url"/>
</j:inputGrid>
<p:separator/>
<j:inputGrid>
<j2:label entity="JeeAttribute"/>
<h:outputText id="test-label-inside-grid" value="j2:label inside of j:inputGrid"/>
<j2:label entity="JeeAttribute" code="label"/>
<h:outputText id="test-does-not-work" value="does not work"/>
@Named @ViewScoped
public class OutputLabelBean extends AbstractJeeBean implements Serializable
{
final static Logger logger = LoggerFactory.getLogger(OutputLabelBean.class);
private static final long serialVersionUID = 1L;
@PostConstruct
public void init()
{
super.initSecurity();
}
public void validate()
{
validated = true;
}
private String field; public String getField() {return field;}
public void setField(String field) {this.field = field;}
private boolean validated; public boolean getValidated() {return validated;}
}