• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get to the custom tags on a page from a scriptlet?

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My colleague has an ASPX page that contains server controls (the equivalent of custom tags in a JSP page). In this page, he has a scriptlet (in C#) that looks up one of the server controls on the page by ID, and then calls a method on it. It looks like this:

So, converted to Java / JSP terminology: he has a scriptlet that looks up a custom tag on the page according to its Id attribute, and then calls a method on the tag handler object for that custom tag.

Is something like this possible when using JSPs?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ewwwwww.

But as far as I know, this isn't possible: the structure of ASP and JSP pages is different; ASP pages are more component-oriented. It'd probably be possible if you were using a component-based page/tag rendering system, but if it's action-based, probably not. The JSP is rendered into a servlet, which is just making function calls to the tag--you'd have to demangle the tag names/instances, and even then, I don't know if it'd work.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Yes, this looked strange to me too, and you probably can't (easily) do the same kind of thing using JSPs. He'll have to find some other way to solve his problem.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I'm missing something, but how is this much different than:



I guess the point is to think about using beans instead of tags/actions. Is there a reason for requiring a tag? Of course, servlets and filters are other options...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because a bean isn't a user-interface component.
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Because a bean isn't a user-interface component.



So, if I used the Struts bean tag instead then it would be a UI component?

Edit: Just goes to show how much that response made my eyes cross, because, you know, <jsp:useBean> really is a tag...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, bean tags aren't UI components either.
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:No, bean tags aren't UI components either.



Got it - this is a "know 'em when I see 'em kind of thing". So, do we know that <prefix:Query> is more like a bean tag or more like a UI component...however that's defined...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic