I need to call a method which will return me a customized message based on screen id and the user role. As there is no provision in JSF, I am not able to do the same, for the reason I am doing work around, even I am not satisfied by with the thing I did. Is there any provision/way that while calling/associating a method to an outputtext I can pass parameters?
Jason Porter wrote:You can do this with JSF 2.0 or use the JBoss EL.
Yes, this is correct. This is one of those hugely powerful but largely unknown features in EE6. As Mr. Porter points out, you can either use EE6 (which currently means Oracle Glassfish) or use something like the JBoss EL on top of Tomcat or Jetty. As an aside, the method invocation features in both projects were largely contributed by Jacob Hookom, inventor of Facelets.
Would you consider this method invocation as a powerful or maybe a dangerous feature? The question may seem stupid but I'm currently working on a project with a self-made view technology which makes extensive use of Java code and method calls inside XML templates. This makes the code and the view templates hard to understand, refactorings are much more difficult as tons of code are buried inside XML files and you always have to be careful when you change some code because the application may fail at runtime even though the Java code itself compiles just fine.
I'm pretty sure that the JSF 2.0 implementation is much more powerful and has better tools support etc. but I think the basic problem stays the same if you allow too much code to creep inside view templates - no matter if it's XML, JSP or XHTML.
What are your opinions on this? Does JSF 2.x help to avoid the trouble? Or should developers take care not to overuse this feature?
Joined: Apr 26, 2007
I'd view this mostly as a tooling concern. I believe the three major IDEs will refactor EL on changes. The inability to call parameterized methods in previous versions of EL I think is crippling, and leads to back end code that is written to work around this limitation. This overall makes code hard to read / understand and maintain.
Of course you're right. The feature comes in handy where needed (instead of creating some dirty hacks in other parts of the application). So maybe tool support would be a good way to avoid problems. I love how NetBeans already handles the mapping between EL properties and code which let's you easily navigate between Java and XHTML. Hopefully future versions will give use advanced features for more complex refactorings etc.
Joined: Jul 17, 2008
The disscussion is really helpful.
I have a little doubt, as Jason suggested I can use JBoss EL to reach the goal, but will it not be a server depencency? How to configure the JBoss EL for my view and how can I use it?
although I've never used it myself I'm pretty sure that JBoss EL in general does not depend on the JBoss server even though the name may suggest it. I think a library for just one small part of the view layer of web apps wouldn't become very popular today if it would bind you to a specific server vendor.
The better question is if and how well it integrates with other web frameworks. Unfortunately I can't answer this question as I haven't yet used it, sorry.
Joined: Jul 17, 2008
Here again, is there any rule needs to be followed to call a parameterized method, I mean normally the method association is the property name ie. if my UserBean is mapped as UserBean and bean definition is
then the call to getUserId() is straight forward and clear to me (it will look for getUserId() method)
but is the following a valid call for method validUserActionsForTheScreen(String, String)?