| Author |
Bean setter methods........
|
Narasimha Rao B.
Ranch Hand
Joined: Aug 26, 2002
Posts: 205
|
|
Hi, 1. If there is no setter method is defined for a bean property will it be an error. In the jsp if we try to set the property value using <jsp:setProperty> what will happen?? 2. If the setter method is present and we are not setting the value by using <jsp:setProperty> or by other means, will the default values(for stings empty sting and for integers 0 like ........) are set for these properties? Thanks in Advance,
|
Narasimha
|
 |
Murali Mohan A
Greenhorn
Joined: Nov 25, 2005
Posts: 4
|
|
----------------------------------------------------------------------- If there is no setter method is defined for a bean property will it be an error. In the jsp if we try to set the property value using <jsp:setProperty> what will happen?? ---------------------------------------------------------------------- For <jsp:setProperty> standard action, Internally JSP implementation object puts code to call setter method on the specified bean and when it doesnt find the setter method definition, it shouts a compile error Murali
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4726
|
|
To answer question 2, the default value will be however you defined the bean class. For instance: (inside a class) private String myValue1; // default is null private String myValue2 = null; // default is also null private String myValue3 = ""; // default is empty string private String myValue4 = "study hard"; // default is study hard // TODO create setter methods later
|
A good workman is known by his tools.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Passing SCJP first should answer question 2 too
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: Bean setter methods........
|
|
|