RequestParameter always null
quaidbrown Jun 3, 2008 3:49 AMI'm trying to get request parameters to work...
I access the unsubscribe.xhtml page below with the url:
localhost:8080/EmailGather2/unsubscribe.seam?pid=abcde
I click the unsubscribe
button, which goes into my stateful session bean's unsubscribe method.
From my reading of the @RequestParameter documentation, the request parameters should be saved into the pid string inside the bean, but it is always null.
Anybody know what I'm doing wrong?
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml"> <ui:define name="body"> <h:graphicImage value="img/logo2.gif" /> <table style="text-align: center" align="center"> <tr> <td style="text-align: left"><br /> <h:form id="emailgather" styleClass="edit" style="text-align:left"> <div class="actionButtons"><h:commandButton type="submit" value="unsubscribe" action="#{unsubscribeAction.unsubscribe}" /> </div> </h:form> <h:messages globalOnly="true" styleClass="message" /></td> </tr> </table> </ui:define> </ui:composition>
import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.jboss.seam.annotations.Begin; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.web.RequestParameter; import static org.jboss.seam.ScopeType.EVENT; @Stateful @Name("unsubscribeAction") @Scope(EVENT) public class UnsubscribeActionBean implements UnsubscribeAction { @PersistenceContext private EntityManager em; @RequestParameter(value="pid") String pid; public void unsubscribe(){ System.out.println(pid); // prints null } @Destroy @Remove public void destroy(){ }