This is my first app using JSF so I'm a little confused. I need to read a value between Managed beans but it is always null no matter how many solutions I try. Recently I noticed that my @PostConstruct method is being called multiple times causing the value to be lost. I already looked at other posts with this issue but haven't been able to solve it.
I'm using JSF 2.2
I appreciate any kind of help, thanks!
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;
import com.tiendavirtual.model.Cliente;
import com.tiendavirtual.model.Compra;
import com.tiendavirtual.model.Item;
import com.tiendavirtual.model.Producto;
import com.tiendavirtual.service.ICompraServiceLocal;
import com.tiendavirtual.service.IProductoServiceLocal;
@ViewScoped
@ManagedBean
public class CompraBean {
@EJB
private ICompraServiceLocal compraService;
@EJB
private IProductoServiceLocal productoService;
private Cliente clienteCarrito;
@PostConstruct
public void init() {
productoActual = new Producto();
itemActual = new Item();
carritoCompra = new ArrayList<Item>();
precioTotal = 0;
cantidadProductosCarrito = 0;
getClienteActual();
}
... setters and getters