You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Enrique Medina <e....@gmail.com> on 2005/03/08 12:35:39 UTC
JSF EL & Method names
As far as I know, the JSF EL allows you to reference object methods this way:
#{myBean.methodName}
I have a method in my UserBean bean named:
public boolean hasOffers()
{
return (this.offers.size() > 0);
}
which determines whether a collection has elements or not.
So in my JSF page I use the following tag:
<h:outputText value="The user has no offers available"
rendered="#{userBean.hasOffers == 'false'}" />
But it doesn't work because I always get a PropertyNotFoundException Sad
So my question is how can I use a method name instead of a property
name in a JSF EL?
Re: JSF EL & Method names
Posted by Heath Borders <he...@gmail.com>.
Anywhere where a ValueBinding is required, you must have either a
BeanInfo defined for the class (I don't know how to do this, I don't
recommend it), or preface your methods with get/set appropriately.
Anywhere where a MethodBinding is required, you need the whole method name.
On Tue, 8 Mar 2005 12:56:20 +0100, Michal Malecki
<mi...@poczta.onet.pl> wrote:
> As far as I know JSF EL allows to use methods in only specific situations
> 1) actions - method has signature String doAction(){}
> 2)events - method has signature void handleEvent(ActionEvent event){}
> and in el: action="#{bean.doAction}" actionListener="#{bean.handleEvent}"
>
> for other situations you must use javabean properties
>
> public boolean isHasOffers()
> {
> return (this.offers.size() > 0);
> }
> public void setHasOffers(boolean b)
> {
> //I think this method must be included, to get type of property
> }
>
> rendered="#{not userBean.hasOffers}" />
>
> Michal Malecki
>
> >
> > As far as I know, the JSF EL allows you to reference object methods this
> way:
> >
> > #{myBean.methodName}
> >
> > I have a method in my UserBean bean named:
> >
> > public boolean hasOffers()
> > {
> > return (this.offers.size() > 0);
> > }
> >
> > which determines whether a collection has elements or not.
> >
> > So in my JSF page I use the following tag:
> >
> > <h:outputText value="The user has no offers available"
> > rendered="#{userBean.hasOffers == 'false'}" />
> >
> > But it doesn't work because I always get a PropertyNotFoundException Sad
> >
> > So my question is how can I use a method name instead of a property
> > name in a JSF EL?
> >
>
>
--
-Heath Borders-Wing
hborders@mail.win.org
Re: JSF EL & Method names
Posted by Michal Malecki <mi...@poczta.onet.pl>.
As far as I know JSF EL allows to use methods in only specific situations
1) actions - method has signature String doAction(){}
2)events - method has signature void handleEvent(ActionEvent event){}
and in el: action="#{bean.doAction}" actionListener="#{bean.handleEvent}"
for other situations you must use javabean properties
public boolean isHasOffers()
{
return (this.offers.size() > 0);
}
public void setHasOffers(boolean b)
{
//I think this method must be included, to get type of property
}
rendered="#{not userBean.hasOffers}" />
Michal Malecki
>
> As far as I know, the JSF EL allows you to reference object methods this
way:
>
> #{myBean.methodName}
>
> I have a method in my UserBean bean named:
>
> public boolean hasOffers()
> {
> return (this.offers.size() > 0);
> }
>
> which determines whether a collection has elements or not.
>
> So in my JSF page I use the following tag:
>
> <h:outputText value="The user has no offers available"
> rendered="#{userBean.hasOffers == 'false'}" />
>
> But it doesn't work because I always get a PropertyNotFoundException Sad
>
> So my question is how can I use a method name instead of a property
> name in a JSF EL?
>