Hi,
i think that if you call property productname the getter should be
getProductname() and not getProductName().
Is it correct?
Bye,
Marco
Hanen Ben Rhouma wrote:
>
> Hello,
>
> Please I have a problem to which I'm stuck since this morning: I am trying
> to render the product list in a jsp page included into a struts 1.3.8
> application and when iterating on the product entity parameters I get this
> exception:
>
> No getter method for property: "productName" of bean: "product"
>
> *
> Here is my Product Class:*
>
> import com.perforce.api.CommitException;
> import com.perforce.api.DirEntry;
> import com.perforce.api.Env;
> import com.perforce.api.HashDecay;
> import com.perforce.api.PerforceException;
> import com.perforce.api.SourceControlObject;
> import java.util.ArrayList;
>
> /**
> *
> * @author hbenrhouma
> */
> public final class Product extends SourceControlObject {
>
> private String id = "";
> private String productname = "";
> private static HashDecay products = null;
>
> /**
> * Default no-argument constructor.
> */
> public Product() {
> super();
> getCache();
> }
>
> /**
> * Constructor that accepts the id of the product. This simply creates
> an
> * instance that has the id set. No other information in the class
> will
> be
> * present until the #sync() sync() method is called.
> *
> * @param id Id for the product.
> */
> public Product(String id) {
> this();
> this.id = id;
> }
>
> private static HashDecay setCache() {
> if (null == products) {
> products = new HashDecay(600000);
> products.start();
> }
> return products;
> }
>
> public HashDecay getCache() {
> return setCache();
> }
>
> public String getId() {
> return id;
> }
>
> public void setId(String id) {
> this.id = id;
> }
>
> public String getProductName() {
> return productname;
> }
>
> public void setProductName(String productname) {
> this.productname = productname;
> }
>
> public static HashDecay getProducts() {
> return products;
> }
>
> public static void setProducts(HashDecay products) {
> Product.products = products;
> }
>
> /**
> * Returns an <code>Enumeration</code> of all <code>Product</code>
> objects.
> */
> public static synchronized ArrayList getProducts(Env env) throws
> Exception {
>
> ArrayList<String> nodes = new ArrayList<String>();
> try {
> DirEntry dir = new DirEntry(env, "//depot/*");
> String[] dirs = dir.getDirNames();
> for (int i = 0; i < dirs.length; i++) {
> nodes.add(dirs[i]);
> }
>
> } catch (Exception ex) {
> throw new Exception("getProducts couldn't be successfully
> executed");
> }
>
> return nodes;
> }
>
> @Override
> public void commit() throws CommitException {
> throw new UnsupportedOperationException("Not supported yet.");
> }
>
> @Override
> public void sync() throws PerforceException {
> throw new UnsupportedOperationException("Not supported yet.");
> }
>
> @Override
> public String toXML() {
> throw new UnsupportedOperationException("Not supported yet.");
> }
> }
>
>
> *Here is the ProductListForm *
>
> import java.util.ArrayList;
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionMapping;
>
> /**
> * Creation date: 14-10-2009
> *
> * @struts.form name="productListForm"
> */
> public class ProductListForm extends ActionForm {
>
> private ArrayList products;
>
> public ArrayList getProducts() {
> return products;
> }
>
> public void setProducts(ArrayList products) {
> this.products = products;
> }
>
> /* 14.10.2009
> * reset the collection products
> */
> @Override
> public void reset(ActionMapping arg0, HttpServletRequest arg1) {
> products = new ArrayList();
> }
>
> /**
> * Method validate
> * @param mapping
> * @param request
> * @return ActionErrors
> */
> @Override
> public ActionErrors validate(ActionMapping mapping,
> HttpServletRequest request) {
> return null;
> }
> }
>
>
> *Here is my ProductListAction*
>
> /**
> * Creation date: 14-10-2009
> *
> *
> * @struts.action path="/productList" name="productListForm"
> scope="request"
> * validate="true"
> * @struts.action-forward name="showProductList"
> path="/jsp/productList.jsp"
> */
> public class ProductListAction extends Action {
>
> /**
> * Method execute
> *
> * @param mapping
> * @param form
> * @param request
> * @param response
> * @return ActionForward
> */
> @Override
> @SuppressWarnings("static-access")
> public ActionForward execute(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response)
> throws
> PerforceException {
> ProductListForm productListForm = (ProductListForm) form;
>
> /*
> * 14.10.2009 load the session facade and get all products
> */
> try {
> productListForm.setProducts(Product.getProducts((Env)
> request.getSession().getAttribute("env")));
> } catch (Exception ex) {
> throw new PerforceException("Error while trying to execute
> productListForm.getProducts method");
> //return mapping.findForward(FAILURE);
> }
> return mapping.findForward("showProductList");
> }
> }
>
> *And last here is **productList.jsp*
>
> <%@ page language="java"%>
> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
>
> <html>
> <head>
> <title>Show Product List</title>
> </head>
> <body bgcolor="#FFFFFF" marginheight="0" marginwidth="0" topmargin="0"
> leftmargin="0">
> <center>
> <TABLE cellspacing="0" cellpadding="0" border="0">
> <table border="1">
> <tbody>
> <%-- set the header --%>
> <tr>
> <td>
> Products
> </td>
>
> </tr>
> <%-- start with an iterate over the collection
> products --%>
> <logic:iterate name="productListForm"
> property="products" id="product">
> <tr>
> <%-- product informations --%>
> <td>
> <bean:write name="product"
> property="productName" />
> </td>
>
> </tr>
> </logic:iterate>
> <%-- end interate --%>
>
> <%-- if products cannot be found display a text
> --%>
> <logic:notPresent name="product">
> <tr>
> <td colspan="5">
> No products found.
> </td>
> </tr>
> </logic:notPresent>
>
> </tbody>
> </table>
> <br>
> </center>
> </body>
> </html>
>
> Please, do you have any idea about what's written wrong here?
>
>
> Thanks in advance,
> Hanen
>
>
--
View this message in context:
http://www.nabble.com/No-getter-method-for-property%3A-%22productName%22-of-bean%3A-%22product%22-tp25893174p25958255.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]