3 Replies Latest reply on Aug 1, 2006 1:11 PM by pasmith

    Post Again:File download dialog apprears instead of page red

    smajima

      I post it again. This time the deference is I used delivered seam-example folder to build my test program.

      I copied registration build file,application.xml,ejb-jar.xml,jboss-app.xml,persistence.xml,faces-config.xml and web.xml.

      I modified application.xml. I used eclipse and did build deploy.
      It succeeded. I tried again my sample,but File download dialog of IE appeared and no page redirection.
      The dialog asked me to donwload success.seam or not.

      Does anybody have the same experience?
      Could you tell me what's wrong?


      My code is

      package seam.register;
      
      import java.util.List;
      
      import javax.annotation.Resource;
      import javax.ejb.SessionContext;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.hibernate.validator.Valid;
      import org.jboss.seam.annotations.IfInvalid;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Outcome;
      import org.jboss.seam.core.FacesMessages;
      
      
      
      @Stateless
      @Name("editcustomer")
      public class EditCustomerAction implements EditCustomer {
      
      
       @In
       @Valid
       private Customer customer;
      
       @PersistenceContext
       private EntityManager em;
      
       @Resource
       SessionContext ctx;
      
       @IfInvalid(outcome=Outcome.REDISPLAY)
       public String register() {
      
       List existing = em.createQuery("select customerId from Customer c where c.customerId=:cid")
       .setParameter("cid", customer.getCustomerId())
       .getResultList();
       if (existing.size()==0)
       {
       em.persist(customer);
       return "/success.jsp";
       }
       else
       {
       FacesMessages.instance().add("Customer already exists");
       return null;
       }
      
       }
      }
      


      JSP calls this session bean is
      <!--
       entry.jsp
      -->
      
      <%@ page contentType="text/html;charset=WINDOWS-31J" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      
      <html>
      <head></head>
      <f:view>
      <body>
       <h:form>
       <table>
       <tr><td>ID:</td>
       <td><h:inputText value="#{customer.customerId}"/></td></tr>
       <tr><td>FirstName:</td>
       <td><h:inputText value="#{customer.firstName}"/></td></tr>
       <tr><td>LastName:</td>
       <td><h:inputText value="#{customer.lastName}"/></td></tr>
       </table>
       <h:messages/>
       <h:commandButton type="submit" value="Register" action="#{editcustomer.register}" />
       </h:form>
      
      
      </body>
      </f:view>
      
      </html>
      


      The JSP above was executed but dialog apeared.
      I don't think the problem is not in build.xml.