Your setter is private. It needs to be public. On Mon, Jul 7, 2008 at 5:49 PM, Chris Miles <[EMAIL PROTECTED]> wrote:
> No exceptions. > > The action class is as follows. > > public class AddToCartAction extends ActionSupport implements Action { > private String productId = ""; > private int quantity = 0; > > private void setProductId(String productId) { > this.productId = productId; > } > > private void setQuantity(int quantity) { > this.quantity = quantity; > } > > public String execute() { > System.out.println("Product Id = " + productId); > System.out.println("Quantity = " + quantity); > return Action.SUCCESS; > } > } > > My struts.xml is > > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE struts PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > > <struts> > <package name="default" extends="struts-default" namespace="/checkout"> > <interceptors> > > <interceptor name="static-params" > class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor" /> > <interceptor name="params" > class="com.opensymphony.xwork2.interceptor.ParametersInterceptor" /> > > <interceptor-stack name="defaultStack"> > <interceptor-ref name="static-params" /> > <interceptor-ref name="params" /> > </interceptor-stack> > > </interceptors> > > <default-interceptor-ref name="defaultStack"/> > > <!-- Product Form / addToCart --> > <action name="viewCart" > class="cakeinabox.struts2.actions.AddToCartAction"> > <result name="success">/jsp/checkout/viewCart.jsp</result> > <result name="error">/jsp/checkout/error.jsp</result> > </action> > </package> > </struts> > > and my JSP is: > > <form action="/checkout/addToCart.action" method="GET"> > <input type="hidden" value="<%=pId%>" name="productId"> > <input type="hidden" value="1" name="quantity"> > .............. > > pId renders as a valid productId in the HTML - this has been checked. > > I have also tried a POST rather than a GET with no joy. > > many thanks > > Chrix > ----- Original Message ----- From: "Musachy Barroso" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <user@struts.apache.org> > Sent: Monday, July 07, 2008 4:46 PM > Subject: Re: Getting Struts2 Parameters? > > > Are there any exceptions in the logs? Does your class implement >> ModelDriven? if you posts the relevant parts of your configuration >> (jsp fragment, action and xml fragment), it will be easier to get >> help. >> >> musachy >> >> On Mon, Jul 7, 2008 at 11:38 AM, <[EMAIL PROTECTED]> wrote: >> >>> In my struts.xml I have set up a stack for "defaultStack" to include the >>> Parameters Interceptor, and I have then set the default stack to >>> "defaultStack". >>> >>> In my action class I have set up a setter injector called >>> setProductId(String productId) which sets to a local variable. >>> >>> I then have a form which points to that action, which is AddToCart.action >>> to be precise. I have an hideen HTML input with the name "productId" and >>> a >>> value set, however when I submit the form the productId variable in the >>> action class has not been set? >>> >>> Is there something obvious that I might be missing? >>> >>> Many thanks and best regards, >>> >>> Chris >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >> >> >> -- >> "Hey you! Would you help me to carry the stone?" Pink Floyd >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> -- >> Internal Virus Database is out-of-date. >> Checked by AVG Free Edition. >> Version: 7.5.446 / Virus Database: 268.18.12/724 - Release Date: >> 16/03/2007 12:12 >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com