File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Help with the Dynamic Attribute API. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help with the Dynamic Attribute API. " Watch "Help with the Dynamic Attribute API. " New topic

Help with the Dynamic Attribute API.

Abhijit Ghatnekar

Joined: Nov 10, 2007
Posts: 19
Hello All,

I want to set up dynamic attributes (and also the optionlist) for some of the <select> dropdowns on one of my site's search page.
Here are the steps that I followed:

1) My Tag Handler class implements the DynamicAttributes.
2) I then overrode the setDynamicAttributes(String uri, String name, Object value) which stores the attribute names and values in a locally declared Hashmap
3) In doTag() method, I retrieved the set of attributes from the Hashmap and generated the dropdowns.
4) I, then configured the 'required' attributes in the TLD and these have setter methods in my tag handler class and I also set the <dynamic-attributes> element to true.

I have 3 questions.

1) I have a total of 6 dropdowns on the page and I want onchange attribute (and a few more) to be added to those. How and where should I call the setDynamicAttributes() attributes method?
2) The optionlist for each of those dropdowns comes up from the DB can you propose any generic code/idea that (it has to be reusable) I can use to fill up the optionlist attribute for the 6 dropdowns? And this code goes in the setter method for optionlist, correct?
3) setDynamicAttributes(String uri, String name, Object value) - I did not understand the purpose of the URI parameter here. Does it denote an XML/XSI namespace or something of that sort?

It is sorta covered in the JavaRanch Style Guide.
subject: Help with the Dynamic Attribute API.
Similar Threads
setDynamicAttributes in Lifecycle of Tag
help please Tags...
Custom Tag
Dynamic attribute
Tutorial on Dynamic Attributes