I want to to write a new custom tag, with several simple attributes. For example
I 've a problem with the method-binding (attribut3). The method doSomething() will be executed before I reached the control over the creation of my custom tag. I have to execute the method doSomething with several parameters, for example doSomething(Class1 obj1, Class2 obj2), from myTag, because this is the place where I create the required method-arguments. So exists there a way to call doSomething "later"? I've looked for an answer to this question, but without any success.
I know it is possible to call from methods inside myTag other methods, but the problem is that the method doSomething has to be dynamic, so that the caller can give his own method/implementation too the tag.
If there exists no common pattern to solve this situation, then I think about the following steps to solve this situation.
1) Do not use a method-binding for attribut3, instead use a value-binding.
2) Give to attribute3 an object which implements an custom interface MyInterface
3) In the methods of myTag then I'm able to call all the desired methods over the (interface-)instance which I passed by the value-expression.
I 've used a way which is quite similar to the interface solution, but I used an abstract class instead of the interface. The benefit of the abstract class is that I need several further (implemented) methods which I inject in my custom tag, and in the abstract class is only be abstract by the sort-method. So everyone who wants to use this tag has to create an instance of my abstract class, override the abstract sort-method, and inject (only) this instance in the tag (by EL).
I think this is a common pattern for solving problems like this.
subject: Execution of method-binding in custom tag