File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on standard actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on standard actions" Watch "Question on standard actions" New topic
Author

Question on standard actions

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

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??


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

or do I just have to switch to EL to get the work done?
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

Yes. The standard actions fail when we want to print the properties of properties. Thanks for the post!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

Can you show that here please?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Assuming that the Person was set as an attribute called "person" :


[My Blog]
All roads lead to JavaRanch
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

Christophe...is there a way to do this using just the standard actions?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Nope, nothing I've heard of. Hail to EL.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9502
    
    2

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

Joined: Feb 18, 2004
Posts: 48
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on standard actions