File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Custom Display Regulator Tag and Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Display Regulator Tag and Interface" Watch "Custom Display Regulator Tag and Interface" New topic

Custom Display Regulator Tag and Interface

Marie Ryan

Joined: Oct 15, 2003
Posts: 1
I have been instructed to write a displayRegulator tag which is intended to control the display of fields (e.g. read-only or an HTML input or hidden altogether). My question is: I need some direction/help/examples with the custom interface and how this would be used (returning READ_ONLY as a static int does what exactly?) I have only written a couple of custom tags, but not any that return anything other than SKIP_BODY, or the standard values.

Here are the details:
The displayRegulator interface has a single method called getVisibility() which returns HIDDEN, READ_ONLY, FULL, or DISABLED. It is designed to control the appearance of fields based on business logic (we are using a configuration framework, where I can get a String that describes the visability type). The idea is that you can control how and if nested tags are shown using your own logic. Consider this example:

<osa:input name="someField" />

When the page renders, the code for myDisplayRegulator tag determines how and if the nested tag is shown by implementing the getVisiblity() method. Your tag should implement the displayRegulator interface to provide the logic for getVisibility() method. If you use the displayReguator interface as it is intended, you will avoid if/then/else conditions within the JSP page.
Steve Leach
Ranch Hand

Joined: Sep 24, 2003
Posts: 46
You have a parent/child relationship between the custom tags, so check out the findAncestorWithClass() method. The input tag would use this to find the MyDisplayRegulator tag so that it can query it.
Your input tag would use pageContext.getOut().print( text ) to output the html code as appropriate.
Is this a student assignment by any chance ?
I agree. Here's the link:
subject: Custom Display Regulator Tag and Interface
It's not a secret anymore!