Hi guys....could you please help me out with this....it's not mentioned in the errata list for HFSJ....The 12th bullet on Page 414 point says --If you specify a "type" attribute in <
jsp:useBean>, you can set properties in <jsp:setProperty> ONLY on properties of the "type", but NOT on properties that exist only in the actual "class" type.(In other words,
polymorphism and normal
Java type rules apply.)
I guess what they meant was THIS :
IF the classes are :
package foo;
public abstract class Person { private
String name;
public void setName(String name) { this.name=name; }
public String getName() {return name;}
}
public class Employee extends Person{ private int empID;
public void setEmpID(int empID){ this.empID=empID; }
public int getEmpID() {return empID;}
}
THEN assuming the bean "testbean" doesn't exist is any of the scopes:
using
<jsp:useBean id="testbean" type="foo.Person" class="foo.Employee" >
<jsp:setProperty name="testbean" property="empID" value="656" />
</jsp:useBean>
would produce an error ....I think that's what they meant and it is justified as well because in Java you cannot do this ...
eg. foo.Person p=new Employee(); p.setEmpID(656)......
BUT...I using
Tomcat 5.0.28 and, tell you what, it works fine when the above useBean code is used ....I'm dazed...please help
[ November 29, 2006: Message edited by: Sayak Banerjee ]