• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tag Library - Common code

 
Sylvia H Charbonneau
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day All !!

This may be totally newbie - but that's ok,I am a newbie.

Anyways, here's how it looks. I've got a custom tag library built by another coder that I'm trying to modify. My modifications involve adding a few variables and initializing those variables. It's a common logging feature I'm trying to implement (log4j). What I'd like to do is declare and initialize everything in one common place. I've done some research, but maybe i'm looking in the wrong place. I almost near the evil point of copying and pasting the exact same code everywhere.

I really am new to Java and O-O. So any help would be greatly appreciated.

Thank you !!
Sylvia
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step away from the Ctrl-C!

If there is common functionality you want to add across the board to a set of custom actions, the best way would be to implement the commmon code in an abstract class which the custom actions would then extend.

Right now, I'm guessing that your actions extend TagSupport. The change would be to declare the abstract base class, let's call it AbstractLoggingTagSupport, which would extend TagSupport instead. This abstract class would contain the common logging support code. Then each individual custom action, by extending this abstract class, automatically inherits the logging suport code.

Would that work for you?
[ May 27, 2004: Message edited by: Bear Bibeault ]
 
Sylvia H Charbonneau
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect !! That worked beautifully ! I still have to flesh it out, but it's working.

Thank you kindly !!

Saved from another Ctrl-C nightmare !

Sylvia
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the world of OO.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!