You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Cosma Colanicchia <co...@gmail.com> on 2006/05/18 10:16:00 UTC

Simple queston on EL syntax

Hi,

I have a problem with EL syntax and cannot found any good reference or
manual on this topic, so I try to ask you :-)
A component in my JSP page <h:outputText value="#{person.fgDismissed == '1'
? 'Yes' : 'No'}"/> that causes the following exception:
javax.faces.FacesException: Cannot get value for expression '#{
person.fgDismissed == '1' ? 'Yes' : 'No'}'

Why it doesn't work? If I simply put an <h:outputText value="#{
person.fgDismissed}"/> the value is correctly printed...

TIA
Cosma

Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Regards struts-shale, I only extracted their custom PropertyResolver,
it's not very complicated if you wanna take a look. It simply checks
if the object is a DynaBean and call, in this case, the methods
get(propertyName) or set(propertyName) otherwise returns the control
to the superclass (the standard property resolver).

My person bean can't be null, because all other fields of the same
bean are correctly rendered. Moreover, as I told before, if I simply
put <h:outputText value="#{person.fgDismissed}"/> (without conditional
expression) the correct value is printed. In this situation, I've
placed a breakpoint on my PropertyResolver getValue method and saw
that the fgDismissed property is returned as a String object.



2006/5/18, Ooschn <Pa...@gmx.de>:
>
> I sometimes just "ask" JSTL whenever I'm in trouble with Bean-Properties.
> Just hava a look what ${person} or ${person.fgDismissed} returns (since
> JSTL-Expressions don't work in JSF jet put it outside the scope of of
> "<f:view>"
>
> Probably it's just that your person == null ?
> I'm familiar with Struts but not with Struts Shale :-/
> --
> View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4448153
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Simple queston on EL syntax

Posted by Ooschn <Pa...@gmx.de>.
I sometimes just "ask" JSTL whenever I'm in trouble with Bean-Properties.
Just hava a look what ${person} or ${person.fgDismissed} returns (since
JSTL-Expressions don't work in JSF jet put it outside the scope of of
"<f:view>"

Probably it's just that your person == null ?
I'm familiar with Struts but not with Struts Shale :-/
--
View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4448153
Sent from the MyFaces - Users forum at Nabble.com.


Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Tried with equal, with and without quotes, and I get an invalid syntax
exception. With eq, again I get the "cannot get value" error.

2006/5/18, Cosma Colanicchia <co...@gmail.com>:
> Ooschn, it must be a String. Maybe the problem is related to the
> custom PropertyResolver from struts-shale: my person bean is a
> DynaBean dynamically generated from a SQL query (and the field is a
> VARCHAR), so in order to access its values I had to provide this
> resolver. Anyway, the exception is thrown before the property resolver
> getValue method is called.. this make me think that the problem is
> related only to the syntax used.
>
>
>
> 2006/5/18, Ooschn <Pa...@gmx.de>:
> >
> > Hi,
> >
> > Is your PersonBean's getFgDismissed() return value really a String?
> > If it is an int or Integer for example, just leave the Single-Quotes:
> >
> > #{person.fgDismissed == '1' ? 'Yes' : 'No'}      ====>
> > #{person.fgDismissed == 1 ? 'Yes' : 'No'}
> > --
> > View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4447816
> > Sent from the MyFaces - Users forum at Nabble.com.
> >
> >
>

Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Ooschn, it must be a String. Maybe the problem is related to the
custom PropertyResolver from struts-shale: my person bean is a
DynaBean dynamically generated from a SQL query (and the field is a
VARCHAR), so in order to access its values I had to provide this
resolver. Anyway, the exception is thrown before the property resolver
getValue method is called.. this make me think that the problem is
related only to the syntax used.



2006/5/18, Ooschn <Pa...@gmx.de>:
>
> Hi,
>
> Is your PersonBean's getFgDismissed() return value really a String?
> If it is an int or Integer for example, just leave the Single-Quotes:
>
> #{person.fgDismissed == '1' ? 'Yes' : 'No'}      ====>
> #{person.fgDismissed == 1 ? 'Yes' : 'No'}
> --
> View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4447816
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Simple queston on EL syntax

Posted by Ooschn <Pa...@gmx.de>.
... or try the following (again consider the Single-Quotes):

#{ person.fgDismissed  equal  1? 'Yes' : 'No'}
--
View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4447862
Sent from the MyFaces - Users forum at Nabble.com.


Re: Simple queston on EL syntax

Posted by Ooschn <Pa...@gmx.de>.
Hi,

Is your PersonBean's getFgDismissed() return value really a String?
If it is an int or Integer for example, just leave the Single-Quotes:

#{person.fgDismissed == '1' ? 'Yes' : 'No'}      ====>  
#{person.fgDismissed == 1 ? 'Yes' : 'No'}
--
View this message in context: http://www.nabble.com/Simple-queston-on-EL-syntax-t1641561.html#a4447816
Sent from the MyFaces - Users forum at Nabble.com.


Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Already tried, this doesn't work :)



2006/5/18, Mike Kienenberger <mk...@gmail.com>:
> On 5/18/06, Cosma Colanicchia <co...@gmail.com> wrote:
> > Both works... maybe that syntax do some check on the bean which isn't
> > catched by the converter, for example it could check the type of the
> > property using introspection..
>
> Well, if both work, try one more thing:
>
> #{(person.fgDismissed == '1') ? 'Yes' : 'No'}
>

Re: Simple queston on EL syntax

Posted by Mike Kienenberger <mk...@gmail.com>.
On 5/18/06, Cosma Colanicchia <co...@gmail.com> wrote:
> Both works... maybe that syntax do some check on the bean which isn't
> catched by the converter, for example it could check the type of the
> property using introspection..

Well, if both work, try one more thing:

#{(person.fgDismissed == '1') ? 'Yes' : 'No'}

Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Both works... maybe that syntax do some check on the bean which isn't
catched by the converter, for example it could check the type of the
property using introspection..

Anyway, I wrote a workaround for the problem using two outputText
components and setting their rendered attribute to
#{person.fgDismissed == '1'}  and its inverse condition.

Thanks for your help OOschn and Julian



2006/5/18, Mike Kienenberger <mk...@gmail.com>:
> Under facelets, I have successfully used expressions like these, but
> facelets uses the EL RI.
>
> ===============
> #{document.dependentEasementDocument != null ?
> document.dependentEasementDocument.easementType.name : 'Permit'}
>
> #{editAuthorizationDocumentPage.displayOnly ? "View" : "Edit"}
>
> Show #{editAuthorizationDocumentPage.displayOnly ? 'View' :
> 'Add/Edit'} Payment Information
> ===============
>
>
> I'd start by trying to simplify your expression to see where it's failing:
>
> <h:outputText value="#{'1' == '1' ? 'Yes' : 'No'}"/>
> <h:outputText value="#{person.fgDismissed == '1'}"/>
>
>
> On 5/18/06, Cosma Colanicchia <co...@gmail.com> wrote:
> > Hi,
> >
> > I have a problem with EL syntax and cannot found any good reference or
> > manual on this topic, so I try to ask you :-)
> > A component in my JSP page <h:outputText value="#{person.fgDismissed == '1'
> > ? 'Yes' : 'No'}"/> that causes the following exception:
> > javax.faces.FacesException: Cannot get value for expression
> > '#{person.fgDismissed == '1' ? 'Yes' : 'No'}'
> >
> > Why it doesn't work? If I simply put an <h:outputText
> > value="#{person.fgDismissed}"/> the value is correctly printed...
> >
> > TIA
> > Cosma
> >
> >
> >
>

Re: Simple queston on EL syntax

Posted by Mike Kienenberger <mk...@gmail.com>.
Under facelets, I have successfully used expressions like these, but
facelets uses the EL RI.

===============
#{document.dependentEasementDocument != null ?
document.dependentEasementDocument.easementType.name : 'Permit'}

#{editAuthorizationDocumentPage.displayOnly ? "View" : "Edit"}

Show #{editAuthorizationDocumentPage.displayOnly ? 'View' :
'Add/Edit'} Payment Information
===============


I'd start by trying to simplify your expression to see where it's failing:

<h:outputText value="#{'1' == '1' ? 'Yes' : 'No'}"/>
<h:outputText value="#{person.fgDismissed == '1'}"/>


On 5/18/06, Cosma Colanicchia <co...@gmail.com> wrote:
> Hi,
>
> I have a problem with EL syntax and cannot found any good reference or
> manual on this topic, so I try to ask you :-)
> A component in my JSP page <h:outputText value="#{person.fgDismissed == '1'
> ? 'Yes' : 'No'}"/> that causes the following exception:
> javax.faces.FacesException: Cannot get value for expression
> '#{person.fgDismissed == '1' ? 'Yes' : 'No'}'
>
> Why it doesn't work? If I simply put an <h:outputText
> value="#{person.fgDismissed}"/> the value is correctly printed...
>
> TIA
> Cosma
>
>
>

Re: Simple queston on EL syntax

Posted by Cosma Colanicchia <co...@gmail.com>.
Thank you Julian, I tried the suggested syntax (slide 65) but it isn't
correct, it uses double quotes in the expression so the JSP can't
correctly parsed. I've tried the same thing with single quotes

value="#{ (person.fgDismissed=='1') ? 'Yes' : 'No' }"

but I got the usual exception..



2006/5/18, Julian Ray <ju...@yahoo.com>:
>
>
>
> This ref might provide some help
>
> http://www.coreservlets.com/JSF-Tutorial/#Section4
>
>  ________________________________
 From: Cosma Colanicchia  [mailto:cosmacol@gmail.com]
> Sent: Thursday, May 18, 2006 4:16  AM
> To: MyFaces Discussion
> Subject: Simple queston on EL  syntax
>
>
>
> Hi,
>
> I have a problem with EL syntax and cannot found any good  reference or manual on this topic, so I try to ask you :-)
> A component in my  JSP page <h:outputText value="#{person.fgDismissed == '1' ? 'Yes' :  'No'}"/> that causes the following exception:
> javax.faces.FacesException:  Cannot get value for expression '#{person.fgDismissed == '1' ? 'Yes' :  'No'}'
>
> Why it doesn't work? If I simply put an <h:outputText  value="#{person.fgDismissed}"/> the value is correctly printed...
>
> TIA
> Cosma
>
>
>
>

RE: Simple queston on EL syntax

Posted by Julian Ray <ju...@yahoo.com>.
This ref might provide some help
 
http://www.coreservlets.com/JSF-Tutorial/#Section4

  _____  

From: Cosma Colanicchia [mailto:cosmacol@gmail.com] 
Sent: Thursday, May 18, 2006 4:16 AM
To: MyFaces Discussion
Subject: Simple queston on EL syntax


Hi,

I have a problem with EL syntax and cannot found any good reference or
manual on this topic, so I try to ask you :-)
A component in my JSP page <h:outputText value="#{person.fgDismissed == '1'
? 'Yes' : 'No'}"/> that causes the following exception: 
javax.faces.FacesException: Cannot get value for expression
'#{person.fgDismissed == '1' ? 'Yes' : 'No'}'

Why it doesn't work? If I simply put an <h:outputText
value="#{person.fgDismissed}"/> the value is correctly printed... 

TIA
Cosma