I tried to check my build file and write tiny program.
The sample registration program delivered with seam did work correctly.
I write sumilar program. It doesn't work correctly.
Instead of page redirection there appears "File download" dialog of IE saying
download success.seam.
Why my program doesn't work.
I use SEAM-1.0.0CR3 + JBOSS4.0.4.GA.
My tiny code is
| package firstseam.action;
|
| import java.io.Serializable;
| 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;
|
|
|
| import firstseam.entity.Customer;
|
| @Stateless
| @Name("editCustomer")
| public class EditCustomerAction implements Serializable, EditCustomer {
|
| /**
| *
| */
| private static final long serialVersionUID = 1L;
|
| @In
| @Valid
| Customer customer;
|
| @PersistenceContext
| EntityManager em;
|
| @Resource
| SessionContext ctx;
|
| @IfInvalid(outcome=Outcome.REDISPLAY)
| public String createCustomer() {
|
| 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("User #{user.username} already
exists");
| return null;
| }
|
| }
|
|
| }
|
ejb-jar.xml file is
| <ejb-jar>
| <assembly-descriptor>
| <interceptor-binding>
| <ejb-name>*</ejb-name>
|
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
| </interceptor-binding>
| </assembly-descriptor>
| </ejb-jar>
|
faces-config.xml is
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!DOCTYPE faces-config
| PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
| "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
|
| <faces-config>
|
| <!-- Phase listener needed for all Seam applications -->
|
| <lifecycle>
|
<phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
| </lifecycle>
|
| </faces-config>
|
|
web.xml is
| <?xml version="1.0" encoding="UTF-8"?>
| <web-app version="2.4"
| xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
|
| <!-- Seam -->
|
| <listener>
| <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
| </listener>
|
| <!-- Global JNDI name pattern for JBoss EJB3 (change for other servers)
-->
| <context-param>
| <param-name>org.jboss.seam.core.init.jndiPattern</param-name>
| <param-value>SeamRegister/#{ejbName}/local</param-value>
| </context-param>
|
| <context-param>
| <param-name>org.jboss.seam.core.init.componentClasses</param-name>
| <param-value></param-value>
| </context-param>
|
| <context-param>
|
<param-name>org.jboss.seam.core.init.myFacesLifecycleBug</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <!-- MyFaces -->
|
| <listener>
|
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
| </listener>
|
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>client</param-value>
| </context-param>
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <!-- Faces Servlet Mapping -->
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.seam</url-pattern>
| </servlet-mapping>
|
| </web-app>
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3956409#3956409
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3956409
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user