You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael Kurz <mi...@gmx.at> on 2010/02/10 09:33:56 UTC
Re: el expression
Hi,
it is true that it is not possible to use method parameters or to call
methods of an object that are no getters or setters (at least before
Java EE 6).
But there are ways to bypass this limitation:
* If you only want to call a method in an EL expression you could define
an EL function (possible with JSP and Facelets).
* If you want to pass a parameter to an action method you could use an
alternative EL implementation like JBoss EL (see [1]). For this you have
to include the JBoss EL libraries and replace the expression factory of
MyFaces like this in your web.xml:
<!-- Replace ExpressionFactory for Apache MyFaces -->
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
regards
Michael
[1]:
http://docs.jboss.org/seam/2.0.1.GA/reference/en/html/elenhancements.html
Am 10.02.2010 09:20, schrieb Martin Monshausen:
> Hi,
> calling methods with parameters is not possible in JSF as far as I know. Try to set Parameter in Bean before calling the method and then refer to it in your parameter-less method.
> Yours,
>
> Martin
> ________________________________
>
> Von: Krishna K. Pandit [mailto:Krishna.Pandit@aptuit.com]
> Gesendet: Mi 10.02.2010 06:14
> An: MyFaces Discussion
> Betreff: el expression
>
>
>
> Hi all
>
> Can any one can help me how to pass a parameter to a method while
> calling it in EL expression.
> Im trying this
>
> "#{myBean.method('JAVA')}
>
> But I m getting errors while rendering.
>
> Thanks
> Krishna Pandit
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you have received this email in error please notify the sender by email
> reply and delete it from your system.
> The integrity and security of this email cannot be guaranteed on the Internet.
>
>
>
>
Re: el expression
Posted by Mark Struberg <st...@yahoo.de>.
done:
http://wiki.apache.org/myfaces/Parameters_In_EL_Functions
http://wiki.apache.org/myfaces/HowToEnableEl22
LieGrue,
strub
--- Matthias Wessendorf <ma...@apache.org> schrieb am Mi, 10.2.2010:
> Von: Matthias Wessendorf <ma...@apache.org>
> Betreff: Re: el expression
> An: "MyFaces Discussion" <us...@myfaces.apache.org>
> Datum: Mittwoch, 10. Februar 2010, 10:36
> thanks mark,
>
> do you mind putting this into a wiki page ? :)
>
> -Matthias
>
> On Wed, Feb 10, 2010 at 10:10 AM, Mark Struberg <st...@yahoo.de>
> wrote:
> > Hiho!
> >
> > It is possible, but only with a little trick.
> > Using a parameter in the EL is a new EL-2.2 feature
> which is _not_ part of JSP-2.1 delivered with tomcat6 and
> jetty6 but defined in JSR-245 MR-2 (JSP-2.2) [1].
> >
> > You can enable EL-2.2 by using a few tricks even in
> tomcat-6 and jetty6.
> > Here is how goes:
> >
> > A.) You have to use el-api.jar and el-impl.jar from
> the glassfish reference implementation. In your pom.xml:
> >
> > <!-- EL 2 -->
> > <dependency>
> > <groupId>javax.el</groupId>
> >
> <artifactId>el-api</artifactId>
> > <version>2.2</version>
> > <scope>provided</scope>
> > </dependency>
> > <profiles>
> > <profile>
> > <id>jetty</id>
> > <build>
> > <plugins>
> > <plugin>
> >
> <groupId>org.mortbay.jetty</groupId>
> >
> <artifactId>maven-jetty-plugin</artifactId>
> >
> <version>${jetty-version}</version>
> >
> <configuration>
> >
> <scanIntervalSeconds>10</scanIntervalSeconds>
> >
> </configuration>
> > </plugin>
> > </plugins>
> > </build>
> > <dependencies>
> > <dependency>
> >
> <groupId>javax.el</groupId>
> >
> <artifactId>el-api</artifactId>
> >
> <version>2.2</version>
> >
> <scope>compile</scope>
> > </dependency>
> > <dependency>
> >
> <groupId>org.glassfish.web</groupId>
> >
> <artifactId>el-impl</artifactId>
> >
> <scope>runtime</scope>
> >
> <version>2.2</version>
> > </dependency>
> > </dependencies>
> > </profile>
> > </profiles
> >
> > This will allow you to use EL-2.2 by running
> > $> mvn clean install -Pjetty jetty:run
> >
> > B.) preparing tomcat
> > 1. go to the tomcat home directory
> > 2. remove tomcats el-api.jar from the classpath:
> > $> mv ./lib/el-api.jar
> ./lib/el-api.jar.nixda
> >
> > 3. copy the EL-2.2 jars into ./lib (el-api-2.2.jar,
> el-impl-2.2.jar)
> > 4. make sure that the applications don't contain
> those 2 el jars!
> >
> > voila, have fun!
> >
> > LieGrue,
> > strub
> >
> > [1] http://jcp.org/aboutJava/communityprocess/mrel/jsr245/index.html
> >
> >
> > --- Michael Kurz <mi...@gmx.at>
> schrieb am Mi, 10.2.2010:
> >
> >> Von: Michael Kurz <mi...@gmx.at>
> >> Betreff: Re: el expression
> >> An: users@myfaces.apache.org
> >> Datum: Mittwoch, 10. Februar 2010, 9:33
> >> Hi,
> >>
> >> it is true that it is not possible to use method
> parameters
> >> or to call
> >> methods of an object that are no getters or
> setters (at
> >> least before
> >> Java EE 6).
> >>
> >> But there are ways to bypass this limitation:
> >>
> >> * If you only want to call a method in an EL
> expression you
> >> could define
> >> an EL function (possible with JSP and Facelets).
> >>
> >> * If you want to pass a parameter to an action
> method you
> >> could use an
> >> alternative EL implementation like JBoss EL (see
> [1]). For
> >> this you have
> >> to include the JBoss EL libraries and replace the
> >> expression factory of
> >> MyFaces like this in your web.xml:
> >>
> >> <!-- Replace ExpressionFactory for
> >> Apache MyFaces -->
> >> <context-param>
> >>
> >>
> <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
> >>
> >>
> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
> >> </context-param>
> >>
> >> regards
> >> Michael
> >>
> >> [1]:
> >> http://docs.jboss.org/seam/2.0.1.GA/reference/en/html/elenhancements.html
> >>
> >> Am 10.02.2010 09:20, schrieb Martin Monshausen:
> >> > Hi,
> >> > calling methods with parameters is not
> possible in JSF
> >> as far as I know. Try to set Parameter in Bean
> before
> >> calling the method and then refer to it in your
> >> parameter-less method.
> >> > Yours,
> >> >
> >> > Martin
> >> > ________________________________
> >> >
> >> > Von: Krishna K. Pandit [mailto:Krishna.Pandit@aptuit.com]
> >> > Gesendet: Mi 10.02.2010 06:14
> >> > An: MyFaces Discussion
> >> > Betreff: el expression
> >> >
> >> >
> >> >
> >> > Hi all
> >> >
> >> > Can any one can help me how to pass a
> parameter to a
> >> method while
> >> > calling it in EL expression.
> >> > Im trying this
> >> >
> >> > "#{myBean.method('JAVA')}
> >> >
> >> > But I m getting errors while rendering.
> >> >
> >> > Thanks
> >> > Krishna Pandit
> >> > This email and any files transmitted with it
> are
> >> confidential and intended
> >> > solely for the use of the individual or
> entity to whom
> >> they are addressed.
> >> > If you have received this email in error
> please notify
> >> the sender by email
> >> > reply and delete it from your system.
> >> > The integrity and security of this email
> cannot be
> >> guaranteed on the Internet.
> >> >
> >> >
> >> >
> >> >
> >>
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> > http://mail.yahoo.com
> >
>
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
Re: el expression
Posted by Matthias Wessendorf <ma...@apache.org>.
thanks mark,
do you mind putting this into a wiki page ? :)
-Matthias
On Wed, Feb 10, 2010 at 10:10 AM, Mark Struberg <st...@yahoo.de> wrote:
> Hiho!
>
> It is possible, but only with a little trick.
> Using a parameter in the EL is a new EL-2.2 feature which is _not_ part of JSP-2.1 delivered with tomcat6 and jetty6 but defined in JSR-245 MR-2 (JSP-2.2) [1].
>
> You can enable EL-2.2 by using a few tricks even in tomcat-6 and jetty6.
> Here is how goes:
>
> A.) You have to use el-api.jar and el-impl.jar from the glassfish reference implementation. In your pom.xml:
>
> <!-- EL 2 -->
> <dependency>
> <groupId>javax.el</groupId>
> <artifactId>el-api</artifactId>
> <version>2.2</version>
> <scope>provided</scope>
> </dependency>
> <profiles>
> <profile>
> <id>jetty</id>
> <build>
> <plugins>
> <plugin>
> <groupId>org.mortbay.jetty</groupId>
> <artifactId>maven-jetty-plugin</artifactId>
> <version>${jetty-version}</version>
> <configuration>
> <scanIntervalSeconds>10</scanIntervalSeconds>
> </configuration>
> </plugin>
> </plugins>
> </build>
> <dependencies>
> <dependency>
> <groupId>javax.el</groupId>
> <artifactId>el-api</artifactId>
> <version>2.2</version>
> <scope>compile</scope>
> </dependency>
> <dependency>
> <groupId>org.glassfish.web</groupId>
> <artifactId>el-impl</artifactId>
> <scope>runtime</scope>
> <version>2.2</version>
> </dependency>
> </dependencies>
> </profile>
> </profiles
>
> This will allow you to use EL-2.2 by running
> $> mvn clean install -Pjetty jetty:run
>
> B.) preparing tomcat
> 1. go to the tomcat home directory
> 2. remove tomcats el-api.jar from the classpath:
> $> mv ./lib/el-api.jar ./lib/el-api.jar.nixda
>
> 3. copy the EL-2.2 jars into ./lib (el-api-2.2.jar, el-impl-2.2.jar)
> 4. make sure that the applications don't contain those 2 el jars!
>
> voila, have fun!
>
> LieGrue,
> strub
>
> [1] http://jcp.org/aboutJava/communityprocess/mrel/jsr245/index.html
>
>
> --- Michael Kurz <mi...@gmx.at> schrieb am Mi, 10.2.2010:
>
>> Von: Michael Kurz <mi...@gmx.at>
>> Betreff: Re: el expression
>> An: users@myfaces.apache.org
>> Datum: Mittwoch, 10. Februar 2010, 9:33
>> Hi,
>>
>> it is true that it is not possible to use method parameters
>> or to call
>> methods of an object that are no getters or setters (at
>> least before
>> Java EE 6).
>>
>> But there are ways to bypass this limitation:
>>
>> * If you only want to call a method in an EL expression you
>> could define
>> an EL function (possible with JSP and Facelets).
>>
>> * If you want to pass a parameter to an action method you
>> could use an
>> alternative EL implementation like JBoss EL (see [1]). For
>> this you have
>> to include the JBoss EL libraries and replace the
>> expression factory of
>> MyFaces like this in your web.xml:
>>
>> <!-- Replace ExpressionFactory for
>> Apache MyFaces -->
>> <context-param>
>>
>> <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
>>
>> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
>> </context-param>
>>
>> regards
>> Michael
>>
>> [1]:
>> http://docs.jboss.org/seam/2.0.1.GA/reference/en/html/elenhancements.html
>>
>> Am 10.02.2010 09:20, schrieb Martin Monshausen:
>> > Hi,
>> > calling methods with parameters is not possible in JSF
>> as far as I know. Try to set Parameter in Bean before
>> calling the method and then refer to it in your
>> parameter-less method.
>> > Yours,
>> >
>> > Martin
>> > ________________________________
>> >
>> > Von: Krishna K. Pandit [mailto:Krishna.Pandit@aptuit.com]
>> > Gesendet: Mi 10.02.2010 06:14
>> > An: MyFaces Discussion
>> > Betreff: el expression
>> >
>> >
>> >
>> > Hi all
>> >
>> > Can any one can help me how to pass a parameter to a
>> method while
>> > calling it in EL expression.
>> > Im trying this
>> >
>> > "#{myBean.method('JAVA')}
>> >
>> > But I m getting errors while rendering.
>> >
>> > Thanks
>> > Krishna Pandit
>> > This email and any files transmitted with it are
>> confidential and intended
>> > solely for the use of the individual or entity to whom
>> they are addressed.
>> > If you have received this email in error please notify
>> the sender by email
>> > reply and delete it from your system.
>> > The integrity and security of this email cannot be
>> guaranteed on the Internet.
>> >
>> >
>> >
>> >
>>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com
>
--
Matthias Wessendorf
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
Re: el expression
Posted by Mark Struberg <st...@yahoo.de>.
Hiho!
It is possible, but only with a little trick.
Using a parameter in the EL is a new EL-2.2 feature which is _not_ part of JSP-2.1 delivered with tomcat6 and jetty6 but defined in JSR-245 MR-2 (JSP-2.2) [1].
You can enable EL-2.2 by using a few tricks even in tomcat-6 and jetty6.
Here is how goes:
A.) You have to use el-api.jar and el-impl.jar from the glassfish reference implementation. In your pom.xml:
<!-- EL 2 -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<profiles>
<profile>
<id>jetty</id>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<scope>runtime</scope>
<version>2.2</version>
</dependency>
</dependencies>
</profile>
</profiles
This will allow you to use EL-2.2 by running
$> mvn clean install -Pjetty jetty:run
B.) preparing tomcat
1. go to the tomcat home directory
2. remove tomcats el-api.jar from the classpath:
$> mv ./lib/el-api.jar ./lib/el-api.jar.nixda
3. copy the EL-2.2 jars into ./lib (el-api-2.2.jar, el-impl-2.2.jar)
4. make sure that the applications don't contain those 2 el jars!
voila, have fun!
LieGrue,
strub
[1] http://jcp.org/aboutJava/communityprocess/mrel/jsr245/index.html
--- Michael Kurz <mi...@gmx.at> schrieb am Mi, 10.2.2010:
> Von: Michael Kurz <mi...@gmx.at>
> Betreff: Re: el expression
> An: users@myfaces.apache.org
> Datum: Mittwoch, 10. Februar 2010, 9:33
> Hi,
>
> it is true that it is not possible to use method parameters
> or to call
> methods of an object that are no getters or setters (at
> least before
> Java EE 6).
>
> But there are ways to bypass this limitation:
>
> * If you only want to call a method in an EL expression you
> could define
> an EL function (possible with JSP and Facelets).
>
> * If you want to pass a parameter to an action method you
> could use an
> alternative EL implementation like JBoss EL (see [1]). For
> this you have
> to include the JBoss EL libraries and replace the
> expression factory of
> MyFaces like this in your web.xml:
>
> <!-- Replace ExpressionFactory for
> Apache MyFaces -->
> <context-param>
>
> <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
>
> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
> </context-param>
>
> regards
> Michael
>
> [1]:
> http://docs.jboss.org/seam/2.0.1.GA/reference/en/html/elenhancements.html
>
> Am 10.02.2010 09:20, schrieb Martin Monshausen:
> > Hi,
> > calling methods with parameters is not possible in JSF
> as far as I know. Try to set Parameter in Bean before
> calling the method and then refer to it in your
> parameter-less method.
> > Yours,
> >
> > Martin
> > ________________________________
> >
> > Von: Krishna K. Pandit [mailto:Krishna.Pandit@aptuit.com]
> > Gesendet: Mi 10.02.2010 06:14
> > An: MyFaces Discussion
> > Betreff: el expression
> >
> >
> >
> > Hi all
> >
> > Can any one can help me how to pass a parameter to a
> method while
> > calling it in EL expression.
> > Im trying this
> >
> > "#{myBean.method('JAVA')}
> >
> > But I m getting errors while rendering.
> >
> > Thanks
> > Krishna Pandit
> > This email and any files transmitted with it are
> confidential and intended
> > solely for the use of the individual or entity to whom
> they are addressed.
> > If you have received this email in error please notify
> the sender by email
> > reply and delete it from your system.
> > The integrity and security of this email cannot be
> guaranteed on the Internet.
> >
> >
> >
> >
>
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com