You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by John Conner <co...@gmail.com> on 2006/07/28 22:08:52 UTC

Rendered propety valid expressions?

I have just started with JSF and have been playing around with el 
expressions in the rendered property of components.  Is there someplace 
that explains what is valid/invalid as an expression for this property?

Specifically is it possible to:
1. Use an and condition like
      rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"

2. Is it possible to compare to an enum value
      rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"

3. Use a complex call like
      rendered="#{mb.someFunction(mb2.value1)}"


Thanks,
- JC

Re: Rendered propety valid expressions?

Posted by John Conner <co...@gmail.com>.
Mike,

Thanks for the info.  I appreciate your help.

- JT

Mike Kienenberger wrote:
> On 7/28/06, John Conner <co...@gmail.com> wrote:
>> I have just started with JSF and have been playing around with el
>> expressions in the rendered property of components.  Is there someplace
>> that explains what is valid/invalid as an expression for this property?
>
> The JSF 1.1 spec (JSR-127) under 5.1.2 "Value Binding Expression
> Syntax", which starts off by saying
>
> "The syntax of a value binding expression is identical to the syntax
> of an expression
> language expression defined in the JavaServer Pages Specification 
> (version 2.0),
> sections 2.3 through 2.9, with the following exceptions..."
>
>
>> Specifically is it possible to:
>> 1. Use an and condition like
>>       rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"
>
> Yes, although I'd recommend using "and" instead of "&&"  (I don't
> remember if it's & or && in any case, but this avoids that issue as
> well as escaping issues).
>
>
>> 2. Is it possible to compare to an enum value
>>       rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"
>
> I don't think so since variables must be managed beans or one of the
> other predefined values.   However, you could write your own resolver
> that also checked for enumeration classes.
>
>> 3. Use a complex call like
>>       rendered="#{mb.someFunction(mb2.value1)}"
>
> Only if you're using Facelets or another viewhandler that lets you
> define functions.
>
> For JSF 1.2, everything is the JSP 2.0 unified EL.   I think this is
> also what Facelets uses underneath as an espression language (I have
> el-api.jar and el-ri.jar files from glassfish to make it work).
>
> In any case, everything about the expression language is configurable.
>  A long while back, someone posted a replacement EL that was
> javascript.
>

Re: Rendered propety valid expressions?

Posted by Mike Kienenberger <mk...@gmail.com>.
On 7/31/06, Jorge Vásquez <jv...@3eyegroup.com> wrote:
> Very interesting!!
> Two new questions regarding valid EL expressions:
> 1.  How exactly will the syntax and procedure be for using a Facelet
> function as rendered condition?

Here's an example that was just posted on the mailing list.

To use it, it'd be

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:myFunction="http://www.prosystemsit.de/le"
      ....

rendered="#{myFunction:test('value')}"

Note that this particular function doesn't return a boolean, so this
would be an error, but it does demonstrate all of the pieces.



---------- Forwarded message ----------
From: Marcus Schmidke <ma...@prosystemsit.de>
Date: Jul 27, 2006 7:09 AM
Subject: Antwort: Re: Re: User defined LE functions
To: MyFaces Discussion <us...@myfaces.apache.org>

web,xml:
 <context-param>
      <param-name>facelets.LIBRARIES</param-name>
      <param-value>/WEB-INF/tags/le.taglib.xml</param-value>
 </context-param>

le.taglib.xml:
<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
      <namespace>http://www.prosystemsit.de/le</namespace>
      <tag>
            <tag-name>test</tag-name>
            <source>test.xhtml</source>
      </tag>
      <function>
            <function-name>wert</function-name>
            <function-class>
de.prosystemsit.leistungserfassung.controller.Functions</function-class>
            <function-signature>java.lang.String
wertInSpalte(java.lang.String)</function-signature>
      </function>
</facelet-taglib>

Functions.java:
package de.prosystemsit.leistungserfassung.controller;

public class Functions {

  public static String wertInSpalte(String s) {
    return "Hallo Welt"+s;
  }
}



> 2.  Is it possible to obtain elements of Lists at specific positions and
> compare them with fixed values.
> Ex:  rendered="#{mb.myList[0] eq 'element1'}"

Sure, if you write a myFunction:listGet(mb.myList, 0) function.

rendered="#{myFunction:listGet(mb.myList, 0) eq 'element1'}"

RE: Rendered propety valid expressions?

Posted by Jorge Vásquez <jv...@3eyegroup.com>.
Very interesting!!
Two new questions regarding valid EL expressions:
1.  How exactly will the syntax and procedure be for using a Facelet
function as rendered condition?
2.  Is it possible to obtain elements of Lists at specific positions and
compare them with fixed values.  
Ex:  rendered="#{mb.myList[0] eq 'element1'}"

Regards,
JV

-----Mensaje original-----
De: Mike Kienenberger [mailto:mkienenb@gmail.com] 
Enviado el: viernes, 28 de julio de 2006 17:36
Para: MyFaces Discussion
Asunto: Re: Rendered propety valid expressions?

Just keep in mind that <, >, & and others are special html characters.

You're better off using and, or, gt, ge, lt, le, eq, ne.

On 7/28/06, Matthias Wessendorf <ma...@apache.org> wrote:
> John,
>
> maybe this gif (JSF 1.1) is helpful too
>
> http://autoren.w3l.de/w3lmedia/W3L/Medium036198/ausdruecke.gif
>
> On 7/28/06, Mike Kienenberger <mk...@gmail.com> wrote:
> > On 7/28/06, John Conner <co...@gmail.com> wrote:
> > > I have just started with JSF and have been playing around with el
> > > expressions in the rendered property of components.  Is there
someplace
> > > that explains what is valid/invalid as an expression for this
property?
> >
> > The JSF 1.1 spec (JSR-127) under 5.1.2 "Value Binding Expression
> > Syntax", which starts off by saying
> >
> > "The syntax of a value binding expression is identical to the syntax
> > of an expression
> > language expression defined in the JavaServer Pages Specification
(version 2.0),
> > sections 2.3 through 2.9, with the following exceptions..."
> >
> >
> > > Specifically is it possible to:
> > > 1. Use an and condition like
> > >       rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"
> >
> > Yes, although I'd recommend using "and" instead of "&&"  (I don't
> > remember if it's & or && in any case, but this avoids that issue as
> > well as escaping issues).
> >
> >
> > > 2. Is it possible to compare to an enum value
> > >       rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"
> >
> > I don't think so since variables must be managed beans or one of the
> > other predefined values.   However, you could write your own resolver
> > that also checked for enumeration classes.
> >
> > > 3. Use a complex call like
> > >       rendered="#{mb.someFunction(mb2.value1)}"
> >
> > Only if you're using Facelets or another viewhandler that lets you
> > define functions.
> >
> > For JSF 1.2, everything is the JSP 2.0 unified EL.   I think this is
> > also what Facelets uses underneath as an espression language (I have
> > el-api.jar and el-ri.jar files from glassfish to make it work).
> >
> > In any case, everything about the expression language is configurable.
> >   A long while back, someone posted a replacement EL that was
> > javascript.
> >
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://jroller.com/page/mwessendorf
> mail: mwessendorf-at-gmail-dot-com
>


Re: Rendered propety valid expressions?

Posted by Mike Kienenberger <mk...@gmail.com>.
Just keep in mind that <, >, & and others are special html characters.

You're better off using and, or, gt, ge, lt, le, eq, ne.

On 7/28/06, Matthias Wessendorf <ma...@apache.org> wrote:
> John,
>
> maybe this gif (JSF 1.1) is helpful too
>
> http://autoren.w3l.de/w3lmedia/W3L/Medium036198/ausdruecke.gif
>
> On 7/28/06, Mike Kienenberger <mk...@gmail.com> wrote:
> > On 7/28/06, John Conner <co...@gmail.com> wrote:
> > > I have just started with JSF and have been playing around with el
> > > expressions in the rendered property of components.  Is there someplace
> > > that explains what is valid/invalid as an expression for this property?
> >
> > The JSF 1.1 spec (JSR-127) under 5.1.2 "Value Binding Expression
> > Syntax", which starts off by saying
> >
> > "The syntax of a value binding expression is identical to the syntax
> > of an expression
> > language expression defined in the JavaServer Pages Specification (version 2.0),
> > sections 2.3 through 2.9, with the following exceptions..."
> >
> >
> > > Specifically is it possible to:
> > > 1. Use an and condition like
> > >       rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"
> >
> > Yes, although I'd recommend using "and" instead of "&&"  (I don't
> > remember if it's & or && in any case, but this avoids that issue as
> > well as escaping issues).
> >
> >
> > > 2. Is it possible to compare to an enum value
> > >       rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"
> >
> > I don't think so since variables must be managed beans or one of the
> > other predefined values.   However, you could write your own resolver
> > that also checked for enumeration classes.
> >
> > > 3. Use a complex call like
> > >       rendered="#{mb.someFunction(mb2.value1)}"
> >
> > Only if you're using Facelets or another viewhandler that lets you
> > define functions.
> >
> > For JSF 1.2, everything is the JSP 2.0 unified EL.   I think this is
> > also what Facelets uses underneath as an espression language (I have
> > el-api.jar and el-ri.jar files from glassfish to make it work).
> >
> > In any case, everything about the expression language is configurable.
> >   A long while back, someone posted a replacement EL that was
> > javascript.
> >
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://jroller.com/page/mwessendorf
> mail: mwessendorf-at-gmail-dot-com
>

window identifier?

Posted by Christopher Cudennec <Sm...@gmx.net>.
Hi everybody,

(how) can I get an identifier for the window of a client request? We 
need to support multiple windows at the same time and therefore can't 
use plain session scoped beans. Using request scoped beans would be too 
expensive, as far as I thought about it ;) . By knowing the window 
identifier one could solve this problem pretty easily. Is that possible?

I found something about a "sequence parameter" but I couldn't find out 
how to use it properly -> I didn't find the documentation. When trying 
it out in my application the sequence parameter always was null. Does it 
only work with forms/posts?

Cheers,

Christopher

Re: Rendered propety valid expressions?

Posted by Matthias Wessendorf <ma...@apache.org>.
John,

maybe this gif (JSF 1.1) is helpful too

http://autoren.w3l.de/w3lmedia/W3L/Medium036198/ausdruecke.gif

On 7/28/06, Mike Kienenberger <mk...@gmail.com> wrote:
> On 7/28/06, John Conner <co...@gmail.com> wrote:
> > I have just started with JSF and have been playing around with el
> > expressions in the rendered property of components.  Is there someplace
> > that explains what is valid/invalid as an expression for this property?
>
> The JSF 1.1 spec (JSR-127) under 5.1.2 "Value Binding Expression
> Syntax", which starts off by saying
>
> "The syntax of a value binding expression is identical to the syntax
> of an expression
> language expression defined in the JavaServer Pages Specification (version 2.0),
> sections 2.3 through 2.9, with the following exceptions..."
>
>
> > Specifically is it possible to:
> > 1. Use an and condition like
> >       rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"
>
> Yes, although I'd recommend using "and" instead of "&&"  (I don't
> remember if it's & or && in any case, but this avoids that issue as
> well as escaping issues).
>
>
> > 2. Is it possible to compare to an enum value
> >       rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"
>
> I don't think so since variables must be managed beans or one of the
> other predefined values.   However, you could write your own resolver
> that also checked for enumeration classes.
>
> > 3. Use a complex call like
> >       rendered="#{mb.someFunction(mb2.value1)}"
>
> Only if you're using Facelets or another viewhandler that lets you
> define functions.
>
> For JSF 1.2, everything is the JSP 2.0 unified EL.   I think this is
> also what Facelets uses underneath as an espression language (I have
> el-api.jar and el-ri.jar files from glassfish to make it work).
>
> In any case, everything about the expression language is configurable.
>   A long while back, someone posted a replacement EL that was
> javascript.
>


-- 
Matthias Wessendorf

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: Rendered propety valid expressions?

Posted by Mike Kienenberger <mk...@gmail.com>.
On 7/28/06, John Conner <co...@gmail.com> wrote:
> I have just started with JSF and have been playing around with el
> expressions in the rendered property of components.  Is there someplace
> that explains what is valid/invalid as an expression for this property?

The JSF 1.1 spec (JSR-127) under 5.1.2 "Value Binding Expression
Syntax", which starts off by saying

"The syntax of a value binding expression is identical to the syntax
of an expression
language expression defined in the JavaServer Pages Specification (version 2.0),
sections 2.3 through 2.9, with the following exceptions..."


> Specifically is it possible to:
> 1. Use an and condition like
>       rendered="#{mb.propertyBoolean1 && mb.propertyBoolean2}"

Yes, although I'd recommend using "and" instead of "&&"  (I don't
remember if it's & or && in any case, but this avoids that issue as
well as escaping issues).


> 2. Is it possible to compare to an enum value
>       rendered="#{mb.enumValue == a.b.c.EnumClass.ENUM_VALUE}"

I don't think so since variables must be managed beans or one of the
other predefined values.   However, you could write your own resolver
that also checked for enumeration classes.

> 3. Use a complex call like
>       rendered="#{mb.someFunction(mb2.value1)}"

Only if you're using Facelets or another viewhandler that lets you
define functions.

For JSF 1.2, everything is the JSP 2.0 unified EL.   I think this is
also what Facelets uses underneath as an espression language (I have
el-api.jar and el-ri.jar files from glassfish to make it work).

In any case, everything about the expression language is configurable.
  A long while back, someone posted a replacement EL that was
javascript.