> For the complete documentation index, see [llms.txt](https://avbravo-2.gitbook.io/trucosjakartaee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://avbravo-2.gitbook.io/trucosjakartaee/overview/java-server-faces/datatable/marcar-como-vistos.md).

# Marcar como vistos

Deseamos que al presionar el boton de marcar los marque como vistos

![](https://2578941663-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lc1Wg6ze2c8GK7mFBZX%2F-LgngC6X0NQk6xfZGLcq%2F-Lgnh6PUYqR6tWf5QWHb%2Fche.png?alt=media\&token=961a7e04-c926-4361-9f13-67e710c28df2)

```markup
 <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

```java
 // <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>
    
```
