خرید بک لینک

Vote count: 0

I can validate a p:selectOneMenu like this:

<p:selectOneMenu id="eventTimezoneDropdown"
        value="#{myBean.eventTimeZone}"
        required="true"
        requiredMessage="The TimeZone must be specified."
        effect="none">
    <f:selectItems value="#{myBean.timeZoneItems}"/>
</p:selectOneMenu>

Conceptually speaking, using a p:dataTable with single row selection will achieve the same goal - it allows you to select one row using a selection attribute instead of value attribute and using value attribute instead of <f:selectItems>.

<p:dataTable id="ActivitiesTable" var="row"
        value="#{myBean.rows}"
        selection="#{myBean.selectedRow}"
        rowKey="#{row.activityId}">
    <p:column selectionMode="single"/>
    ...
</p:dataTable>

However I don't see any validation options (e.g. a required attribute) on the p:dataTable.

Is there a way or workaround to have a required selection validation on a p:dataTable similar to the required attribute on p:selectOneMenu?

Environment: Primefaces 5.3, JSF 2.2.8-14, Tomcat 7.0.68.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 29 خرداد 1395 ساعت: 0:02

صفحه بندی