Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Chris Riesbeck Newsgroups: comp.lang.java.programmer Subject: Re: JSF 1.2 Date: Wed, 13 Jul 2011 13:17:18 -0500 Lines: 48 Message-ID: <9865pfF2qeU1@mid.individual.net> References: <4e1d5166$0$1538$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net wlSzxtljQhDRfu52HkPxGwWzAow298vXdq+0gVSn5NaFywzYpU Cancel-Lock: sha1:nEsL97W34o2elHbI0JulK8cW3TM= User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: <4e1d5166$0$1538$426a74cc@news.free.fr> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6167 On 7/13/2011 3:03 AM, Pif - 34 wrote: > Hello, > > I'm working on a project based on JSF1.2. In a XHTML document, I must > call a method using a parameter. > > So, since this is not possible directly using standard syntax, I would > like to know if one of following solutions is possible that cut be > usefull in my code: > > - use an include of a JSP template that do the code I need to place ? In > a doc, you can only include > - include a JSP tag in the that allow to place javacode ? > > Do you have Id of workarounds ? For just one such method, you can create a function you can call in the JSP expression language. Just two steps: - in an appropriate class, define a static method - in a TLD file, declare the function Details at http://download.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html If I have many such methods, I define one "call" method in some utility class (error checking code removed) and the associated TLD public static Object call(final Object obj, final String methodName, final Object arg) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return obj.getClass() .getMethod(methodName, arg.getClass()) .invoke(obj, arg); } then I can write expressions like the following, where au is the prefix for my tag library: "${au:call(user, 'getDomainRoles', domain)}" to call user.getDomainRoles(domain)