Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question on standard actions

 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE 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: 10192
3
Mac PPC Eclipse IDE 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?
 
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: 10192
3
Mac PPC Eclipse IDE 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: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show that here please?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • 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: 10192
3
Mac PPC Eclipse IDE 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 VI Editor Ubuntu
  • 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: 10192
3
Mac PPC Eclipse IDE 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!
 
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 ]
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic