Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:06:46+00:00 2026-06-17T00:06:46+00:00

I’m having the following issue with a dataTable using PrimeFaces 3.4.1 and JSF 2.1.6.

  • 0

I’m having the following issue with a dataTable using PrimeFaces 3.4.1 and JSF 2.1.6. First time the page loads, the dataTable is filled with data from our database, but whenever an action is executed on the page (edit link, dataTable sort or filtering), the dataTable loses its data. DataTable has elements from this class:

package es.cne.sicbios.entities.tramites.envios;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataContactoEconomico;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataEmpresaFilial;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataHistoricoTipoSujeto;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataPersonaContacto;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataPlantaProduccion;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataRepresentante;
import es.cne.sicbios.entities.tramites.envios.sujeto.data.EnvioDataSujeto;
import es.cne.sicbios.entities.tramites.solicitudes.SolicitudSujeto;

@SuppressWarnings("serial")
@Entity
public class EnvioSujeto extends Envio implements Serializable{

@ManyToOne(optional = false, cascade = CascadeType.ALL)
private SolicitudSujeto solicitud;

@OneToOne(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private EnvioDataContactoEconomico envioDataContactoEconomico;

@OneToMany(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private List<EnvioDataEmpresaFilial> enviosDataEmpresaFilial;

@OneToMany(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private List<EnvioDataHistoricoTipoSujeto> enviosDataHistoricoTipoSujeto;

@OneToMany(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private List<EnvioDataPlantaProduccion> enviosDataPlantaProduccion;

@OneToOne(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private EnvioDataSujeto envioDataSujeto;

@OneToMany(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private List<EnvioDataPersonaContacto> enviosDataPersonaContacto;

@OneToMany(mappedBy = "envioSujeto", cascade = CascadeType.ALL)
private List<EnvioDataRepresentante> enviosDataRepresentante;

public SolicitudSujeto getSolicitud() {
    return solicitud;
}

public void setSolicitud(final SolicitudSujeto solicitud) {
    this.solicitud = solicitud;
}

... //rest of getters and setters
}

When debugging after an action is taken on the dataTable, we keep data only on the envioDatasujeto field, every other data on the element is lost.

Here’s the xhtml:

<ui:composition template="/templates/layout.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:blb="http://ecb.bilbomatica.es/components">

    <ui:define name="content">
        <f:loadBundle basename="es.cne.sicbios.gestionsujetos" var="gestionmsg" />
        <h:form id="formulario">
            <p:messages id="messages" showDetail="true" autoUpdate="true"
                closable="true" />

                <p:dataTable var="envioSujeto"
                value="#{listadoEnviosSujetoMB.lazyListaAllEnvios}" 
                paginator="true" rows="10"
                paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                rowsPerPageTemplate="5,10,15"               
                selectionMode="single"  
                selection="#{listadoEnviosSujetoMB.envioSeleccionado}" 
                id="listaEnviosSujetos" 
                lazy="true">

                <f:facet name="header">  
                    #{gestionmsg.txt_listadoEnviosSujetos} 
                </f:facet>

                <p:column sortBy="#{envioSujeto.envioDataSujeto.datosSujeto.acronimo}" headerText="#{gestionmsg.column_acronimo}"
                    filterBy="#{envioSujeto.envioDataSujeto.datosSujeto.acronimo}">
                    <h:outputText value="#{envioSujeto.envioDataSujeto.datosSujeto.acronimo}" />                    
                </p:column>

                <p:column sortBy="#{envioSujeto.solicitud.id}"
                    headerText="#{gestionmsg.column_id_tramite}"
                    filterBy="#{envioSujeto.solicitud.id}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.solicitud.id}" />                    
                </p:column>

                <p:column sortBy="#{envioSujeto.fechaCreacion.time}"
                    headerText="#{gestionmsg.column_fechaCreacion}"
                    filterBy="#{envioSujeto.fechaCreacion.time}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.fechaCreacion.time}" >
                        <f:convertDateTime pattern="dd/mm/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column sortBy="#{envioSujeto.tipo}"
                    headerText="#{gestionmsg.column_tipoEnvio}"
                    filterBy="#{envioSujeto.tipo}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.tipo}" />
                </p:column>

                <p:column sortBy="#{envioSujeto.solicitud.estado}"
                    headerText="#{gestionmsg.column_estado}"
                    filterBy="#{envioSujeto.solicitud.estado}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.solicitud.estado}" />
                </p:column>

                <p:column sortBy="#{envioSujeto.idRegistro}"
                    headerText="#{gestionmsg.column_idRegistro}"
                    filterBy="#{envioSujeto.idRegistro}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.idRegistro}" />
                </p:column>

                <p:column sortBy="#{envioSujeto.id}"
                    headerText="id"
                    filterBy="#{envioSujeto.id}"
                    filterMatchMode="contains">
                    <h:outputText value="#{envioSujeto.id}" />
                </p:column>
                <ui:remove>
                <!-- 
                <p:column 
                    headerText="#{gestionmsg.column_bloqueo}"
                    >
                    <h:outputText value="" />
                </p:column>
                 -->
                 </ui:remove>

            </p:dataTable>

            <p:commandLink icon="ui-icon-pencil"
                update=":formulario"
                actionListener="#{listadoEnviosSujetoMB.goToEditarEnvio}"  >    
                <h:outputText value="Editar" />                                         
            </p:commandLink>
        </h:form>
    </ui:define>
</ui:composition>

And the managed bean for it:

package es.cne.sicbios.managedbean.gestionsujetos;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import es.cne.sicbios.entities.tramites.envios.Envio;
import es.cne.sicbios.services.tramites.envios.IEnvioService;
import es.cne.sicbios.utils.FacesUtils;

@SuppressWarnings("serial")
@ViewScoped
@ManagedBean(name = "listadoEnviosSujetoMB")
public class ListadoEnviosSujetoMB implements Serializable {

@ManagedProperty(value = "#{envioSujetoService}")
private IEnvioService envioService;
private Envio envio;
private List<Envio> listaAllEnvios;
private LazyEnvioSujetoDataModel lazyListaAllEnvios;
private Envio envioSeleccionado;

/**
 * 
 * Getters y Setters
 */
@PostConstruct
public void init(){
    if (lazyListaAllEnvios == null) {
        lazyListaAllEnvios = new LazyEnvioSujetoDataModel(envioService);
    }
}

public void setEnvioService(final IEnvioService envioService) {
    this.envioService = envioService;
}

public Envio getEnvio() {
    return envio;
}

public void setEnvio(final Envio envio) {
    this.envio = envio;
}

public List<Envio> getListaAllEnvios() {
    if (listaAllEnvios == null) {
        listaAllEnvios =  envioService.getAll();
    }
    return listaAllEnvios;
}

public void setListaAllEnvios(final List<Envio> listaAllEnvios) {
    this.listaAllEnvios = listaAllEnvios;
}

public Envio getEnvioSeleccionado() {
    return envioSeleccionado;
}

public void setEnvioSeleccionado(final Envio envioSeleccionado) {
    this.envioSeleccionado = envioSeleccionado;
}

/**
 * Métodos de navegación
 */
public String goToEditarEnvio() {
    FacesUtils.saveObjectInFlashScope("envio", envioSeleccionado);
    return "/pages/gestionsujetos/envio.xhtml?faces-redirect=true";
}

public LazyEnvioSujetoDataModel getLazyListaAllEnvios() {
    return lazyListaAllEnvios;
}

public void setLazyListaAllEnvios(final LazyEnvioSujetoDataModel lazyListaAllEnvios) {
    this.lazyListaAllEnvios = lazyListaAllEnvios;
}
}

Also, we tried to do a lazy load of the data, but it doesn’t work. This is the data model we used (an adapted class from the Lazy Loading example on PrimeFaces.org):

package es.cne.sicbios.managedbean.gestionsujetos;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ViewScoped;

import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SelectableDataModel;
import org.primefaces.model.SortOrder;

import es.cne.sicbios.entities.tramites.envios.Envio;
import es.cne.sicbios.services.tramites.envios.IEnvioService;

/**
 * Dummy implementation of LazyDataModel that uses a list to mimic a real datasource like a database.
 */
@ViewScoped
public class LazyEnvioSujetoDataModel extends LazyDataModel<Envio> implements Serializable, SelectableDataModel<Envio> {

/**
 * 
 */
private static final long serialVersionUID = 983251078912322527L;
private final List<Envio> datasource;


public List<Envio> getDatasource() {
    return datasource;
}

public LazyEnvioSujetoDataModel(final IEnvioService envioService) {
    this.datasource = envioService.getAll();
}

@Override
public Envio getRowData(final String rowKey) {
    for(final Envio envio : datasource) {
        if(envio.getId().equals(rowKey))
            return envio;
    }

    return null;
}

@Override
public Object getRowKey(final Envio envio) {
    return envio.getId();
}

@Override
public List<Envio> load(final int first, final int pageSize,
        final String sortField, final SortOrder sortOrder, final Map<String,String> filters) {
    final List<Envio> data = new ArrayList<Envio>();

    //filter
    for(final Envio envio : datasource) {
        boolean match = true;

        for(final Iterator<String> it = filters.keySet().iterator(); it.hasNext();) {
            try {
                final String filterProperty = it.next();
                final String filterValue = filters.get(filterProperty);
                final String fieldValue = String.valueOf(envio.getClass().getField(filterProperty).get(envio));

                if(filterValue == null || fieldValue.startsWith(filterValue)) {
                    match = true;
                }
                else {
                    match = false;
                    break;
                }
            } catch(final Exception e) {
                match = false;
            }
        }

        if(match) {
            data.add(envio);
        }
    }

    //sort
    //      if(sortField != null) {
    //          Collections.sort(data, new LazySorter(sortField, sortOrder));
    //      }

    //rowCount
    final int dataSize = data.size();
    this.setRowCount(dataSize);

    //paginate
    if(dataSize > pageSize) {
        try {
            return data.subList(first, first + pageSize);
        }
        catch(final IndexOutOfBoundsException e) {
            return data.subList(first, first + (dataSize % pageSize));
        }
    }
    else {
        return data;
    }
}
}

Any idea for this problem?
Thanks in advance,
Juanjo.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:06:47+00:00Added an answer on June 17, 2026 at 12:06 am

    A friend of the teamwork get the answer for this issue. We’re using the Spring Tool Suite, and sometimes it was changing the saving method for JSF’s managed beans. We need to have this on our web.xml :

    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.