• 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 change tag body and evaluate it dynamically ?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a tag inside which a few other tags can be used OR can be used in
any order. An end user decides which tag ('s info) to display or in what
order. For example,

example 1:

<example:A>
<example:b/>
<example:c/>
<example />
</example:A>

example 1:

<example:A>
<example />
<example:b/>
</example:A>

I hope to write a SINGLE JSP page that can display info in the above examples' way.

I am trying to write a custom tag which is used in the following way:

<example:A>
<example:generate/>
</example:A>

The job of the generate tag is dynamically creating a string such as

<example /><example:b/>

and inserting it into the body of tag A and evalute its body.

I have tried both simple tags and classic tags but have failed to
create a solution. I cannot find a way to manipulate the tag body and
evaluate it dynamically.

Am I doing the right thing? Is it possible for me to create a solution based
on the current JSP specification? Any other ways of doing this type of thing?

Really hope to hear from JSP/tag experts on this forum.

Thanks very much in advance!!

Pete.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are trying to do is not possible. Custom tags are converted to code at translation time. When the tags execute at a later time and emit custom tag syntax into the output stream, the emitted tags will be uninterpreted as the translation cycle will not occur again.
 
pete johnson
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much for your input. I know I can do achieve the same goal
purely based on servlets which outputs different pieces of info in
various orders.

Do you know of any other solution that is more elegant?

Regards.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm actually not completely clear on what you are trying to achieve. Why not try to describe what you need at a slightly higher level?
 
pete johnson
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, it is about displaying information in a table.
The table has many columns and users can select, via a browser interface,
any columns to display and specify the order (from left to right)
selected columns to display on the results page.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I have set up something similar.

The system generates web reports. The end user (it's a logged in system) can specify "column preferences" such as which of the available columns for a report are to be included, the column order, initial sort, and even formatting options on a per-column basis. And since the report results can run into tens of throusands of rows, they can also specify a "page size" and extensive report filters.

Each user's "column preferences" are stored in the DB. On the report pages there is a "report" tag that identifies the report to be generated. The tag handles generating the HTML table for the report results, as well as relevant controls for filtering and paging. This is all generated using the dataset returned from the report query, as well as from the column prefs which are read from the DB and stored in Java objects that model the preference values.

So, the tag structure on the page is incredibly simple. Something along the lines of (simplified to show only relevant details):



As the tag code has access to the pageContext and hence the session, it can obtain the column prefs from the user info stored in the session for the logged-in user.

The id attribute specifies which report is to being generated. The formName attribute gives the HTML name of the form in which this report is enclosed. This form is submitted by code generated from the tag whenever a column header is clicked (for sorting), paging is requested, or a filter is changed.

The relevant part of all this is that the "column preferences" aren't specified on-page in any tags like you were attempting to do. The prefs are stored on a per-user basis in the DB and modeled using Java objects that the "report" tag uses to generate its output.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic