Marcar como vistos
Last updated
Was this helpful?
Last updated
Was this helpful?
Deseamos que al presionar el boton de marcar los marque como vistos
<jmoordbjsf:paginator
controller="#{jmoordbNotificationsController}"
renderedNew="false"
renderedPrint="false"
rowPage="#{jmoordbNotificationsController.rowPage}"
page="#{jmoordbNotificationsController.page}"
pages="#{jmoordbNotificationsController.pages}"
skip="ajax:jmoordbNotificationsController.skip()"
url = "/pages/jmoordbNotifications/new.xhtml"
/>
<b:dataTable value="#{jmoordbNotificationsController.jmoordbNotificationsDataModel}"
var="item"
id="dataTable2"
paginated="false"
onpage="console.log('page');">
<b:dataTableColumn value="#{item.idjmoordbnotifications}" label="#{app['field.idjmoordbnotifications']}"/>
<b:dataTableColumn value="#{item.message}" label="#{app['field.message']}"/>
<b:dataTableColumn value="#{item.type}" label="#{app['field.type']}"/>
<b:dataTableColumn value="#{jmoordbNotificationsController.showDate(item.date)}" label="#{app['field.date']}"/>
<b:dataTableColumn value="#{item.viewed}" label="#{app['field.viewed']}" />
<b:dataTableColumn label="">
<b:commandButton action="#{jmoordbNotificationsController.markAsViewed(item)}"
iconAwesome="fa-check-square-o"
update=":form:dataTable, :form:msgs"/>
</b:dataTableColumn>
</b:dataTable>
En el Controller
// <editor-fold defaultstate="collapsed" desc="marcarComoVistos(JmoordbNotifications item)">
public String markAsViewed(JmoordbNotifications item){
try {
jmoordbNotificationsDataModel = new JmoordbNotificationsDataModel(jmoordbNotificationsList);
//Marca como vistas las notificaciones
Integer count = 0;
for (JmoordbNotifications jn : jmoordbNotificationsList) {
if (jn.getIdjmoordbnotifications().equals(item.getIdjmoordbnotifications())) {
jmoordbNotificationsList.get(count).setViewed("si");
jn.setViewed("si");
jmoordbNotificationsRepository.update(jn);
}
count++;
}
jmoordbNotificationsDataModel = new JmoordbNotificationsDataModel(jmoordbNotificationsList);
JsfUtil.successMessage("Marcados como vistos");
} catch (Exception e) {
errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
}
return "";
}// </editor-fold>