2 Replies Latest reply on Sep 19, 2006 12:19 PM by Reginaldo L. Russinholi

    Problem to submit a form with commandButton

    Reginaldo L. Russinholi Newbie

      Hi all,

      I'm new using JSF and i'm trying to create a application like the DVDStore example.

      I have a form that represents an EntityBean "atdo" and a SLSB called "atdoAction" that persist this "atdo".

      Well, my problem is that when a click on the button of my xhtml page to call the "atdoAction.save" method the application simply return to the same page without call the method. But when I set "immediate" parameter of commandButton to "true", then the application call the method, but the informations supplied on form isn't attributed to de "atdo" object.

      My test.xhtml page:
      #some code before

      <h:form >
       <h:inputHidden value="#{atdo.codigo}" />
       <h:panelGrid columns="2" >
       <h:outputText value="Codigo Cliente:"/>
       <h:inputText value="#{atdo.codigoCliente}" title="CodigoCliente" />
       <h:outputText value="Solicitante:"/>
       <h:inputText value="#{atdo.solicitante}" title="Solicitante" />
       <h:outputText value="Obs:"/>
       <h:inputTextarea value="#{atdo.obs}" title="Obs" />
       <h:commandButton type="submit" action="#{atdoAction.save}" value="Criar Atendimento"/>

      #some code after

      My atdoAction:
      public class AtendimentoBean implements AtendimentoLocal, AtendimentoRemote {
       EntityManager em;
       UserTransaction utx;
       AtendimentoEntity atdo;
       public String save() throws Exception {
       try {
       } catch (Exception e) {
       throw new Exception(e.getMessage());
       return "success";

      My "atdo"
      @SequenceGenerator(name = "atendimento_seq", sequenceName = "atendimento_codigo_seq", allocationSize=1)
      @Table(name = "atendimento", uniqueConstraints = {
       @UniqueConstraint(columnNames = { "protocolo" }) })
      public class AtendimentoEntity implements Atendimento{
       private Integer codigo;
       private String obs;
       private String solicitante;
       private String codigoCliente;
       @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="atendimento_seq")
       @Column(name = "codigo", unique = true, nullable = false, insertable = true, updatable = true)
       public Integer getCodigo() {
       return codigo;
       public void setCodigo(Integer codigo) {
       this.codigo = codigo;
       @Column(name = "cliente", unique = false, nullable = false, insertable = true, updatable = true, length=10)
       public String getCodigoCliente() {
       return codigoCliente;
       public void setCodigoCliente(String codigoCliente) {
       this.codigoCliente = codigoCliente;
       @Column(name = "obs", unique = false, nullable = false, insertable = true, updatable = true)
       public String getObs() {
       return obs;
       public void setObs(String obs) {
       this.obs = obs;
       @Column(name = "solicitante", unique = false, nullable = false, insertable = true, updatable = true, length=50)
       public String getSolicitante() {
       return solicitante;
       public void setSolicitante(String solicitante) {
       this.solicitante = solicitante;

      So, if someone could help me, I'd be very thanked.

      Reginaldo L. Russinholi
      System Analyst / Developer
      Sun Certified Java Programmer