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:
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.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Custom Display Regulator Tag and Interface