[jboss-user] [JBoss Seam] - Problem to submit a form with commandButton

bagrehc do-not-reply at jboss.com
Tue Sep 19 10:09:13 EDT 2006


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:panelGrid>
  |           	<h:commandButton type="submit" action="#{atdoAction.save}" value="Criar Atendimento"/>  
  |         </h:form>
  | 
#some code after
-------

My atdoAction:
----------------------
@TransactionManagement(TransactionManagementType.BEAN)  
  | @Stateless
  | @Name("atdoAction")
  | public class AtendimentoBean implements AtendimentoLocal, AtendimentoRemote {
  | 
  |     @PersistenceContext(unitName="atendimento")
  |     EntityManager em;
  | 
  |     @Resource
  |     UserTransaction utx;
  |     
  |     @In
  |     AtendimentoEntity atdo;
  | 
  |     public String save() throws Exception {
  |         try {
  |             utx.begin();
  |             
  |             em.persist(atdo);                
  |             utx.commit();
  |             
  |         } catch (Exception e) {            
  |             utx.rollback();
  |             
  |             e.printStackTrace();
  |             throw new Exception(e.getMessage());
  |         }
  |         
  |         return "success";
  |     }
  | }
  | -----------------------------------

My "atdo" 
-----------------------------------
@Name("atdo")
  | @Scope(ScopeType.SESSION)
  | @SequenceGenerator(name = "atendimento_seq", sequenceName = "atendimento_codigo_seq", allocationSize=1)
  | @Entity
  | @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;
  |     }
  | 
  | 
  |     @Lob
  |     @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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972585#3972585

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972585



More information about the jboss-user mailing list