You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hanen Ben Rhouma <ha...@gmail.com> on 2009/10/14 17:17:46 UTC
No getter method for property: "productName" of bean: "product"
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 <a href="#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>
<b>Products</b>
</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
Re: No getter method for property: "productName" of bean: "product"
Posted by Alessio Mereu <gr...@gmail.com>.
According the code You've posted in your first email (and trimming off not
relevant parts):
public final class Product extends SourceControlObject {
>
> ....
>
> 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("....");
> }
>
> return nodes;
> }
>
> ....
>
> }
>
This method returns an ArrayList containing Strings.
public class ProductListForm extends ActionForm {
>
> private ArrayList products;
>
> public ArrayList getProducts() {
> return products;
> }
>
> public void setProducts(ArrayList products) {
> this.products = products;
> }
>
> ....
> }
>
Simply a getter and setters for products
public class ProductListAction extends Action {
> @Override
> @SuppressWarnings("static-access")
> public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest
> request, HttpServletResponse response) throws PerforceException {
> ProductListForm productListForm = (ProductListForm) form;
> 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("showProductList");
> }
> }
>
The action SETS the ArrayList 'products' of the form using the value
returned from Product.getProducts(Env env) , so if your problem depends from
the code above... the cause is clear. You set an ArrayList of Strings in
your form and the page iterate over this array that contain Strings and not
Product objects as you expeted.
It's obvious that if you fill the array of the form with an array containing
Product objects tha jsp has no errors, but the action posted above fills the
array with an array of strings.
Alessio Mereu
PS. sorry for my english :(
2009/10/19 Hanen Ben Rhouma <ha...@gmail.com>
> Hello,
>
> @Alessio: I don't think so. Actually, I'm using ArrayList in my form so
> it's
> assumed that it would contain any Object (no restriction there) so when I
> fill it with Product It can cast it (well, that's what I think at least).
>
> @Marco: I'll try that maybe it's one reason
>
>
> Thanks a lot for all your comments!
> Hanen
>
>
> On Mon, Oct 19, 2009 at 2:33 PM, Alessio Mereu <grugno.mezzorco@gmail.com
> >wrote:
>
> > Product.getProducts(Env ) returns an ArrayList<String> not an
> > ArrayList<Product> as U're supposing according your jsp.
> >
> > So that the iteration is made over a list of Strings and Strings has no
> > property nor getters for ProductName
> >
> > Is it correct?
> >
> > Alessio
> >
> >
> >
> > 2009/10/19 mlivro79 <ma...@livrieri.it>
> >
> > >
> > > 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: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>
Re: No getter method for property: "productName" of bean: "product"
Posted by Hanen Ben Rhouma <ha...@gmail.com>.
Hello,
@Alessio: I don't think so. Actually, I'm using ArrayList in my form so it's
assumed that it would contain any Object (no restriction there) so when I
fill it with Product It can cast it (well, that's what I think at least).
@Marco: I'll try that maybe it's one reason
Thanks a lot for all your comments!
Hanen
On Mon, Oct 19, 2009 at 2:33 PM, Alessio Mereu <gr...@gmail.com>wrote:
> Product.getProducts(Env ) returns an ArrayList<String> not an
> ArrayList<Product> as U're supposing according your jsp.
>
> So that the iteration is made over a list of Strings and Strings has no
> property nor getters for ProductName
>
> Is it correct?
>
> Alessio
>
>
>
> 2009/10/19 mlivro79 <ma...@livrieri.it>
>
> >
> > 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: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Re: No getter method for property: "productName" of bean: "product"
Posted by Alessio Mereu <gr...@gmail.com>.
Product.getProducts(Env ) returns an ArrayList<String> not an
ArrayList<Product> as U're supposing according your jsp.
So that the iteration is made over a list of Strings and Strings has no
property nor getters for ProductName
Is it correct?
Alessio
2009/10/19 mlivro79 <ma...@livrieri.it>
>
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: No getter method for property: "productName" of bean: "product"
Posted by mlivro79 <ma...@livrieri.it>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org