I have a problem. I have a form with inputs to be sent to a bean by , the thing is debugged, in the bean object is always null. Could you help me with this.
Here the code:
<h:form id="frmNuevo">
<p:dialog id="dialog" header="Añadir Presupuesto" widgetVar="dialogNuevo" resizable="true" width="500" height="500" showEffect="fade" hideEffect="explode" modal="true">
<p:growl id="growl" showDetail="true" sticky="true" />
<h:panelGrid id="display" columns="2" cellpadding="4" style="margin: 0 auto;">
<h:outputText value="Diciembre:" />
<p:inputText value="#{presupuestoBean.presupuesto.diciembre}" required="true" maxlength="20" />
<p:commandButton value="Guardar" update=":form:cars, frmNuevo, growl, display" process="@this" actionListener="#{presupuestoBean.insertar}" oncomplete="dialogNuevo.hide()" image="icon-save" />
<p:commandButton value="Cancelar" update=":form:cars" oncomplete="dialogNuevo.hide()" style="margin-bottom: 20px;" image="icon-cancel" />
</h:panelGrid>
<p:separator/></p:dialog>
</h:form>
I tested with SessionScoped and RequestScoped and does not work, the strange thing is I have done other similar beans and if they work ManagedBean:
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@ManagedBean(name = "presupuestoBean")
@RequestScoped
public class PresupuestoBean implements Serializable {
private TbPresupuesto presupuesto;
private List<TbPresupuesto> presupuestos;
private UploadedFile file;
private String destination = "C:\\temp\\";
public PresupuestoBean() {
presupuesto = new TbPresupuesto();
presupuestos = new ArrayList();
}
public TbPresupuesto getPresupuesto() {
return presupuesto;
}
public void setPresupuesto(TbPresupuesto presupuesto) {
this.presupuesto = presupuesto;
}
public void prepararInsertar() {
presupuesto = new TbPresupuesto();
presupuestos = new ArrayList();
}
public void insertar() {
PresupuestoDaoImpl presupuestoDao = new PresupuestoDaoImpl();
presupuesto.setPresupuestoId(presupuesto.getLinea().getLineaId());
presupuestoDao.insertar(presupuesto);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Se ha ingresado correctamente"));
presupuesto = new TbPresupuesto();
}
}