aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Display Regulator Tag and Interface" Watch "Custom Display Regulator Tag and Interface" New topic
Author

Custom Display Regulator Tag and Interface

Marie Ryan
Greenhorn

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:myDisplayRegulator>
<osa:input name="someField" />
</osa:myDisplayRegulator>

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: http://aspose.com/file-tools
 
subject: Custom Display Regulator Tag and Interface
 
Similar Threads
custom tag and beans
Tag library
about struts
Doubts in Mock exam HFSJ
Writing Image Bytes on Response Stream