Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to specify resources for your custom tag component  RSS feed

 
Gaurav Gupta
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to build a custom component which displays a table with specific colomns ...like text in first two colomns, icons in next three colomns.
This table diplsay will obviously use some css to style my text and some img files to display images.
Now, I want to build my tag such that:
Apart from providing data for table content, user can also specify his own css files and his own images if he wants to. If he doesnt want then he can use the default css and images.
Pls note- this is to be coded as a component.
How can I set my attributes for css and images? what should be the directory structure of this component? How can user override the default resource file by specifying his own?
Thanks,
gaurav
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best way to do this is to either provide a ResourceBundle the user can use (which is basically a properties-file) or to allow the data to be passed in as parameters (maybe using a special tag for setting them, which stores the data in the pageContext where the other tags can then read it).
The first would be appropriate for global data that's the same all the time (like a site-wide stylesheet) only, the second for page-specific data or instance-specific data.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!