Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSF 1.2

Reply
Thread Tools

JSF 1.2

 
 
Pif - 34
Guest
Posts: n/a
 
      07-13-2011
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 <html ... > doc, you can only include <html subdocs ?

- include a JSP tag in the <html> that allow to place javacode ?

Do you have Id of workarounds ?

Thanks a lot.
 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      07-13-2011
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 <html ... > doc, you can only include <html subdocs ?
>
> - include a JSP tag in the <html> 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....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)


 
Reply With Quote
 
 
 
 
lewbloch
Guest
Posts: n/a
 
      07-13-2011
On Jul 13, 11:17*am, Chris Riesbeck <Chris.Riesb...@gmail.com> wrote:
> 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 <html ... > doc, you can only include <html subdocs ?

>
> > - include a JSP tag in the <html> 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....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)


Why are people discussing JSP when the OP states that the problem is
in XHTML?

There are other ways, too - for example, set a member variable in a
page-level bean instead of passing a method argument.

I thought EL allowed passing arguments to methods. I will have to
research this. It's a problem I've faced before but I don't remember
the solution off the top of my head. I'll be back on that.

--
Lew
 
Reply With Quote
 
Travers Naran
Guest
Posts: n/a
 
      07-18-2011
On 13/07/2011 11:32 AM, lewbloch wrote:
> I thought EL allowed passing arguments to methods. I will have to
> research this. It's a problem I've faced before but I don't remember
> the solution off the top of my head. I'll be back on that.


Not in JSF 1.2. It's in JSF 2.0.

Although this post suggests it can be done by just changing other base
technology versions:
http://stackoverflow.com/questions/5...rameter-in-jsf
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Include JSF page within another JSF page BlackIce Java 1 07-05-2006 11:24 PM
JSF debugging / JSF newsgroup Sebastian Fey Java 1 04-07-2006 08:52 PM
[JSF]Need to deploy a jsf application on SunApplicationServer. dudu Java 0 03-03-2006 12:09 PM
Is JSF ready to take on ASP.NET? Patrick.O.Ige ASP .Net 1 02-20-2006 04:25 PM
JSP, JSF and template based rendering for components Javaholic Java 1 07-14-2003 07:17 PM



Advertisments