• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on standard actions

 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I've rarely used standard actions till now. I have a small question concerning it's
usage. They are considered helpful when we want to print the properties of a
javabean with the condition that those properties are either Strings or primitives.
If those properties are themselves references to another javabean, then better use EL.
Am I right on this?? One more question for this would be from the example that
is given in the Head First book as below,



Now how to print the name of the Dog through the use of standard actions?

<jsp:useBean id="person" class="foo.Person" scope="request"/>
Dog's name is: <jsp:getProperty name="person" property="dog" />

But the above line prints the object...how to get it print the actual Dog's name by just
using the standard actions??
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or do I just have to switch to EL to get the work done?
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think it is better to switch EL. <jsp:getProperty name="person" property="dog" /> will print everything as String. I think this standard action is not best suited for nested properties.

You can also use the existing class in useBean action in EL.

But using EL you can not set properties.

Thanks
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The standard actions fail when we want to print the properties of properties. Thanks for the post!
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show that here please?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that the Person was set as an attribute called "person" :
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe...is there a way to do this using just the standard actions?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, nothing I've heard of. Hail to EL.
 
Joe Harry
Ranch Hand
Posts: 10080
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was some post here that said we can do it and I asked that person to show that here...I guess he has removed his post from here. Anyways, I understood the fact and I have to switch over to EL. Thanks guys for the help!
 
Tamer Badr
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to do it using standard actions, this is the main reason why we use EL [HFSJ (Chapter 8 page 364)].
[ October 18, 2007: Message edited by: Tamer Badr ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic