aspose file tools*
The moose likes JSP and the fly likes deciphering param attribute in setProperty jsp action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "deciphering param attribute in setProperty jsp action?" Watch "deciphering param attribute in setProperty jsp action?" New topic
Author

deciphering param attribute in setProperty jsp action?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

the hfsj book at page no 360 says that

The param attribute lets you set the value of a
bean property to the value of a request parameter.
JUST by naming the request parameter!

<jsp:useBean id=”person” type=”foo.Person” class=”foo.Employee”>
<jsp:setProperty name=”person” property=”name” param=”userName” />
</jsp:useBean>


my question it that useBean has a body which contains setProperty. this body runs CONDITIONALLY if there is no attribute with the name "person" in the page scope. so lets say that there IS an attribute with the name "person" in the page scope. in that case the body of useBean tag won't run and hence there WONT be any setting of the name property of person object as is said in above lines from the book. am i right ? am i missing something ? please help
Regards
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1017
Your interpretation is correct.
You do not appear to be missing anything.

The tags nested within a useBean tag are executed only when it is instantiating the bean.

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Stefan Evans wrote:Your interpretation is correct.
You do not appear to be missing anything.

The tags nested within a useBean tag are executed only when it is instantiating the bean.



thanks. but the book says that param attribute helps in set the value of a property to request parameter. but if the person attribute already exists in the given scope the set property tag won't even run and hence the param attribute wont be able to set the property. so this means only if person attribute is NOT in the scope does above statement has meaning. but the book makes a statement that param attribute sets the property.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: deciphering param attribute in setProperty jsp action?