wood burning stoves 2.0*
The moose likes Struts and the fly likes My Opinion on JSF Method Binding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "My Opinion on JSF Method Binding" Watch "My Opinion on JSF Method Binding" New topic
Author

My Opinion on JSF Method Binding

Dushy Inguva
Ranch Hand

Joined: Jun 24, 2003
Posts: 264
In JSF, we can specify the method to be executed when an event occurs. (Very similar to a observer-observable)
But, there are no interfaces to implement. You just give the method name in the xml file (faces-config.xml) and make sure the method has a particular set of parameters.

Thats like using function pointers. In my opinion, a better way of doing it would have been what Swing does. With event listeners. (There ARE event listers in JSF) just that method binding is not architected like one.
More details: Page 5-6 Section 5-2 of the JSF Specification 1.0

What do you think about this?


SJCP, SCBCD, SJCD, SCDJWS, SCEA (Part I)
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Maybe this solution was chosen in order not to become intrusive. What I mean is: if I do not have to implement any interface (as it is required in an event handling mechanism) and I am able to bind any method than my code remains absolutely unlinked to the JSF.

my 2c
./pope


blog - InfoQ.com
Dushy Inguva
Ranch Hand

Joined: Jun 24, 2003
Posts: 264
If "un-intrusiveness" was the factor, I'm not sure if they totally achieved it.
1. Some of the methods have to return a string which decides how the navigation will be performed. (This is a contract between the bean developer and the framework and hence is a lockin).
2. It is not that our methods can have whatever signature we like. Some methods need to accept a list of JSF specific parameters, which very much binds us to the framework. The only "wriggle room" we get is the name of the method, which can be anything.
3. To indicate an exception, we need to throw a sub class of a runtime FacesException(i don't have anything against runtime exceptions, i think thats really not the focus of this discussion). But, what i want to point to is, we already will be using JSF specific exception hierarchy.
4. In anycase, if we have to be framework independent, a layer can be provided by the application developers (or any other framework that builds over JSF). Struts achieves the same by urging developers not to code business rules in action classes.

I do not say that an application needs/doesnot need to be JSF application independent. Thats the decision of the architect. In anycase, not using interfaces to achieve the contract between JSF and the application would not alter that decision in any manner.

I'm not totally sure that not using interfaces for this reason is a valid argument. They do provide compile time type checking and a clean and object oriented way of method invocation (virtual functions). Whereas, the approach taken relies on "function pointers".

I understand that JSF is supposed to be "tooled", and the tools will/need to provide compile time checking, but giving up on object oriented ness to depend on a tool does not convince me enough. It also becomes difficult to use existing code checkers or other optimizers etc on code which lacks compile time type checking.
[ October 26, 2004: Message edited by: Dushy Inguva ]
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Even if I totally agree with you that imposing the signature is not very non-intrusive, you must not missunderstand the difference between contracts and intrusive.

./pope
Dushy Inguva
Ranch Hand

Joined: Jun 24, 2003
Posts: 264
Pope,

I don't know if my understanding is wrong, and I don't mean to be rude, but I think a contract by itself does impose an amount of 'dependence' which brings in intrusive-ness.

That is why, we usually use an extra "mapping/shielding" layer to prevent a framework lockin. Please feel free to correct me.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Agree with you that dependency brings in a way intrusion... but a method signature cannot be considered an intrusion.

./pope

ps: we got to stop this :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My Opinion on JSF Method Binding
 
Similar Threads
struts or JSF
i have a doubt: who knows the performance of using JSF as view?
Problem with JSF remembering old values
Opening Multiple Windows from a Single JSF CommandButton click
JSF Binding Components