aspose file tools*
The moose likes JSF and the fly likes Execution of method-binding in custom tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Execution of method-binding in custom tag" Watch "Execution of method-binding in custom tag" New topic
Author

Execution of method-binding in custom tag

Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hello,

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.

Every comment, answer and opinion is welcome.

Best regards,
Christian Nicoll


SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hey Ranchers, not all together .

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.

Best regards,
Christian Nicoll
 
jQuery in Action, 2nd edition
 
subject: Execution of method-binding in custom tag