• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

can custom tags accept java objects as attrbutes?

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have never gone beyond a "hello world" example when it comes to custom tags.
We have decided to go struts way for our project.
I was wondering if a custom tag c'd accept a Enumeration object and run through it displaying the contents on the browser?
If custom tags are a replacement for a scriptlets then this s'd work??.
<%
while(enum.hasMoreElements(){%>
<%= enum.next()%>
<%}
%>
can this be replaced with a tag that takes the enum object as a parameter / attribute and do the rendering internal to the tag class?
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by karthik Guru:
[QB]I was wondering if a custom tag c'd accept a Enumeration object and run through it displaying the contents on the browser?


Yes, JSP supports the idea of an rtexprvalue (request-time expression value). Rtexprvalues use the familiar <%= ... %> syntax inside the attribute value. For instance:

To let your tag accept rtexprvalues, you can add a sub-element that looks like

to any of your tag's <attribute> elements in its tag-library descriptor (TLD) file.
Note that rtexprvalue, and other uses of <% ... %> in general, depend on using Java code inside your JSP pages, which is generally regarded as a practice that leads to poor maintainability. To avoid Java code and rtexprvalues, you can use JSTL, the new JSP Standard Tag Library. JSTL lets you pass data between tags using an expression language, so you can say

instead of

For more information on JSTL, see
http://java.sun.com/products/jsp/jstl
I'm happy to answer any JSTL question you have; I'm its reference-implementation lead and have written an upcoming book that explains all of JSTL's details. Hope that helps!
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot! it worked.
is JSTL in beta or something?
if it is, then we w'd'nt be able to use it.
If otherwise that will be great.
and a
<special-request>
Am a great fan of manning books!. i own 2 books Object Oriented Perl and Server based java programming from manning.
OOPerl is probably one of the best texts i have ever read on a language. For me it is one of those classics.
I normally read the sample chapters from manning site and i find most of them ot be excellent.
Manning unfortunately did'nt publish any other
books in India, where i come from.
Buying books @ US rates turn out to be pretty expensive here.
(most of the books have indian editions).
Can you try getting this thought across to manning publishers?
We have a sizeable IT population and manning w'd probably benefit a lot by publishing them here
(orielly, Addision wesley etc are very popular here)
</special-request>

thanks,
karthik
reply
    Bookmark Topic Watch Topic
  • New Topic