f:validateRequired

The f:validateRequired Facelet tag can be used to require a value from a UIInput Component. f:validateRequired activates the same validation logic as required="true" and UIInput.setRequired(true).

共通 Usage




                   

ソースコード

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html">

	<h:form>
		<label class="control-label">#{i18n['required']}</label>
		<h:inputText id="required" value="#{inputTextModelBean.text}"
			label="#{i18n['f-validaterequired-label']}">
			<f:validateRequired />
		</h:inputText>
		<br />
		<h:message for="required" />
		<hr />
		<h:commandButton value="#{i18n['submit']}">
			<f:ajax	execute="@form" render="@form" />
		</h:commandButton>
		<h:outputText value="#{inputTextModelBean.text}" />
	</h:form>

</ui:composition>
@ManagedBean
@RequestScoped
public class InputTextModelBean {

	private Date date = new GregorianCalendar().getTime();
	private String text;

	public Date getDate() {
		return date;
	}

	public String getText() {
		return text;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setText(String text) {
		this.text = text;
	}
}
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20