Sathish David Kumar N
asked on
pblm with property in xml file
Hi ,
<bean name="/hello.do"
class="springapps.controll er.HelloCo ntroller">
<property name="ProduectBean" ref="ProduectBean"></prope rty>
</bean>
which name i want to give in the property name ..
error is
org.springframework.beans. factory.Be anCreation Exception: Error creating bean with name '/hello.do' defined in ServletContext resource [/WEB-INF/SpringApps-servl et.xml]: Error setting property values; nested exception is org.springframework.beans. NotWritabl ePropertyE xception: Invalid property 'ProduectBean' of bean class [springapps.controller.Hel loControll er]: Bean property 'ProduectBean' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
can anyone tell me ..
what values we want put it in property !!
<bean name="/hello.do"
class="springapps.controll
<property name="ProduectBean" ref="ProduectBean"></prope
</bean>
which name i want to give in the property name ..
error is
org.springframework.beans.
can anyone tell me ..
what values we want put it in property !!
whats your controller look like?
ASKER
My Xml File
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="product" class="springapps.service.simpleProductManager">
<property name="product">
<list>
<ref bean="pro1" />
<ref bean="pro2" />
</list>
</property>
</bean>
<bean id="pro1" class="springapps.Bean.ProduectBean">
<property name="product_no" value="00001"></property>
<property name="product_details" value="s/w product"></property>
<property name="price" value="200"></property>
</bean>
<bean id="pro2" class="springapps.Bean.ProduectBean">
<property name="product_no" value="00002"></property>
<property name="product_details" value="machanic product"></property>
<property name="price" value="5000"></property>
</bean>
<bean name="/hello.do"
class="springapps.controller.HelloController">
<property name="product" ref="product"></property>
</bean>
<bean id="viewReslover"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView">
</property>
<property name="prefix" value="/Jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
My Controller
public class HelloController implements Controller{
private ProductInter productInter;
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
{
String now =(new Date()).toString();
System.out.println("inside controller");
Map myModel=new HashMap();
myModel.put("now",now);
myModel.put("pro",this.productInter.getProduct());
return new ModelAndView("hello","myModel",myModel);
}
public void SetProductInter(ProductInter productInter) {
productInter = productInter;
}
}
ProductInter is an inter face thats have two methods called getProdect and incresePrice
Which name i want to mention in the proerty !!
y we mention can any one explain in this
>
looks like name should be: productInter
*but* the ref also appears wrong I don't see any bean name ProduectBean, nor any bean of type ProduectInter that I can see
Your controller also needs a getter method and the name of the setter should be setProductInter
looks like name should be: productInter
*but* the ref also appears wrong I don't see any bean name ProduectBean, nor any bean of type ProduectInter that I can see
Your controller also needs a getter method and the name of the setter should be setProductInter
ASKER
this what productBean i set the values of the bean in the xml file
public class ProduectBean implements Serializable{
private String product_no;
private String product_details;
private int price;
public String getProduct_no() {
return product_no;
}
public void setProduct_no(String product_no) {
this.product_no = product_no;
}
public String getProduct_details() {
return product_details;
}
public void setProduct_details(String product_details) {
this.product_details = product_details;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
simpleProductManager is productInter implemented one
public class simpleProductManager implements ProductInter {
private List product;
public int increasePrice(){
return 1;
}
public List getProduct()
{
return product;
}
public void setProduct(List product)
{
this.product=product;
}
}
this what my whole code
can u tell me now !!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i did a small mistake ...very chily mistake
in controler setter method i put S as caps ...
thanks man !!