You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mick Knutson <mi...@gmail.com> on 2006/11/01 01:52:47 UTC
Solved, but not happy with solution Re: question about BackingBeans and POJO's
I solved the issue, but am not happy with it.
It seems that using a dot notation in the Resource Bundle is not allowed.
This gives me the error:
<h:outputText value="#{messages.label.firstName}" />:
This does not:
<h:outputText value="#{messages.label_firstName}" />:
But I had to change my messages.properties declaration from:
label.firstName=First Name
to:
label_firstName=First Name
On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
>
> What is the UserBackingBeanBeanInfo ???
>
> All I have is a simple UserBackingBeanBean with a set/get for public User
>
>
>
>
>
> On 10/31/06, Simon Kitching <si...@rhe.co.nz> wrote:
> >
> > Well,everything does seem to be right. However the original exception
> > does say:
> >
> > javax.faces.el.PropertyNotFoundException: Bean: java.lang.String ,
> > property: firstName
> > at
> > org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor (
> > PropertyResolverImpl.java:483)
> >
> > which seems to imply that getUser has returned a String object.
> >
> > The PropertyResolverImpl code is:
> > public static PropertyDescriptor getPropertyDescriptor(
> > BeanInfo beanInfo, String propertyName)
> > {
> > PropertyDescriptor[] propDescriptors =
> > beanInfo.getPropertyDescriptors();
> >
> > if (propDescriptors != null)
> > {
> > // TODO: cache this in classLoader safe way
> > for (int i = 0, len = propDescriptors.length; i < len; i++)
> > {
> > if (propDescriptors[i].getName().equals(propertyName))
> > return propDescriptors[i];
> > }
> > }
> >
> > throw new PropertyNotFoundException("Bean: "
> > + beanInfo.getBeanDescriptor().getBeanClass().getName()
> > + ", property: " + propertyName);
> > }
> >
> >
> > You don't happen to have a UserBackingBeanBeanInfo class around do you?
> >
> > As a wild guess, is the User class public? Maybe if it isn't, then
> > something in the java introspection or JSF el code is calling toString
> > on it to convert it to something that is accessable..
> >
> > I can't think what else might be causing your issue..
> >
> > Cheers,
> >
> > Simon
> >
>
>
>
> --
>
> Thanks
>
> DJ MICK
> http://www.djmick.com
> http://www.myspace.com/mickknutson
>
--
Thanks
DJ MICK
http://www.djmick.com
http://www.myspace.com/mickknutson
Re: Solved, but not happy with solution Re: question about BackingBeans
and POJO's
Posted by Jeff Bischoff <jb...@klkurz.com>.
Thanks for the explanation Wendy, Craig. ;)
Re: Solved, but not happy with solution Re: question about BackingBeans and POJO's
Posted by Wendy Smoak <ws...@gmail.com>.
On 11/1/06, Jeff Bischoff <jb...@klkurz.com> wrote:
> >> EL expressions use the same syntax for variable references that
> >> JavaScript
> >> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and
> >> "#{foo['bar']}"
> >> are all equivalent.
>
> If they are equivalent, then why didn't his original syntax work? I've
> seen the pattern you suggested used in the Tomahawk examples and
> elsewhere, but I never knew why it was necessary.
The original example had three parts: "messages.label.firstName".
In this case, I think it's necessary to use brackets so you get
something like messages.get( "label.firstName" ) and not
messages.getLabel().getFirstName().
--
Wendy
Re: Solved, but not happy with solution Re: question about BackingBeans and POJO's
Posted by Craig McClanahan <cr...@apache.org>.
On 11/1/06, Jeff Bischoff <jb...@klkurz.com> wrote:
>
> >> EL expressions use the same syntax for variable references that
> >> JavaScript
> >> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and
> >> "#{foo['bar']}"
> >> are all equivalent.
>
> If they are equivalent, then why didn't his original syntax work? I've
> seen the pattern you suggested used in the Tomahawk examples and
> elsewhere, but I never knew why it was necessary.
Technically, my second alternative (#{foo[bar]) is only equivalent *if*
there are no periods in the "bar" part of the expression.
The original question was about using the <f:loadBundle> tag to expose a
ResourceBundle as a map, and then using expressions to look them up. Like
many people, he had used message keys with periods in them ("login.prompt").
Trying to evaluate "#{messages.login.prompt}" or "#{messages[login.prompt]}"
will not work correctly, because the "." character inside is treated as an
operator. But "#{messages['login.prompt']}" succeeds because "login.prompt"
is treated as a single value instead.
Regards.
>
> Jeff Bischoff
> Kenneth L Kurz & Associates, Inc.
Craig
Mick Knutson wrote:
> > <h:outputText value="#{messages['label.firstName']}"/>
> >
> > This worked great, and I don't have to change all my Resource Bundles
> now.
> >
> > Thank you so much!!!
> >
> >
> >
> > On 10/31/06, Craig McClanahan <cr...@apache.org> wrote:
> >>
> >>
> >>
> >> On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
> >> >
> >> > I solved the issue, but am not happy with it.
> >> > It seems that using a dot notation in the Resource Bundle is not
> >> > allowed.
> >>
> >>
> >> Hold up a sec on the changes!
> >>
> >> EL expressions use the same syntax for variable references that
> >> JavaScript
> >> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and
> >> "#{foo['bar']}"
> >> are all equivalent.
> >>
> >> This gives me the error:
> >> > <h:outputText value="#{messages.label.firstName}" />:
> >>
> >>
> >> Try this instead:
> >>
> >> <h:outputText value="#{messages['label.firstName']}"/>
> >>
> >> Craig
> >>
> >> This does not:
> >> > <h:outputText value="#{messages.label_firstName}" />:
> >> >
> >> > But I had to change my messages.properties declaration from:
> >> > label.firstName=First Name
> >> >
> >> > to:
> >> >
> >> > label_firstName=First Name
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On 10/31/06, Mick Knutson < mickknutson@gmail.com> wrote:
> >> > >
> >> > > What is the UserBackingBeanBeanInfo ???
> >> > >
> >> > > All I have is a simple UserBackingBeanBean with a set/get for
> public
> >> > > User
> >> > >
> >> > >
> >> > >
> >> > >
> >> > >
> >> > > On 10/31/06, Simon Kitching <si...@rhe.co.nz> wrote:
> >> > > >
> >> > > > Well,everything does seem to be right. However the original
> >> > > > exception
> >> > > > does say:
> >> > > >
> >> > > > javax.faces.el.PropertyNotFoundException: Bean: java.lang.String,
> >> > > > property: firstName
> >> > > > at
> >> > > > org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(
> >> > > > PropertyResolverImpl.java:483)
> >> > > >
> >> > > > which seems to imply that getUser has returned a String object.
> >> > > >
> >> > > > The PropertyResolverImpl code is:
> >> > > > public static PropertyDescriptor getPropertyDescriptor(
> >> > > > BeanInfo beanInfo, String propertyName)
> >> > > > {
> >> > > > PropertyDescriptor[] propDescriptors =
> >> > > > beanInfo.getPropertyDescriptors();
> >> > > >
> >> > > > if (propDescriptors != null)
> >> > > > {
> >> > > > // TODO: cache this in classLoader safe way
> >> > > > for (int i = 0, len = propDescriptors.length; i <
> len;
> >> > > > i++)
> >> > > > {
> >> > > > if
> >> > > > (propDescriptors[i].getName().equals(propertyName))
> >> > > > return propDescriptors[i];
> >> > > > }
> >> > > > }
> >> > > >
> >> > > > throw new PropertyNotFoundException("Bean: "
> >> > > > + beanInfo.getBeanDescriptor
> ().getBeanClass().getName()
> >> > > > + ", property: " + propertyName);
> >> > > > }
> >> > > >
> >> > > >
> >> > > > You don't happen to have a UserBackingBeanBeanInfo class around
> do
> >> > > > you?
> >> > > >
> >> > > > As a wild guess, is the User class public? Maybe if it isn't,
> then
> >> > > > something in the java introspection or JSF el code is calling
> >> > > > toString
> >> > > > on it to convert it to something that is accessable..
> >> > > >
> >> > > > I can't think what else might be causing your issue..
> >> > > >
> >> > > > Cheers,
> >> > > >
> >> > > > Simon
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > >
> >> > > Thanks
> >> > >
> >> > > DJ MICK
> >> > > http://www.djmick.com
> >> > > http://www.myspace.com/mickknutson
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >> > Thanks
> >> >
> >> > DJ MICK
> >> > http://www.djmick.com
> >> > http://www.myspace.com/mickknutson
> >>
> >>
> >>
> >
> >
>
>
>
Re: Solved, but not happy with solution Re: question about BackingBeans
and POJO's
Posted by Jeff Bischoff <jb...@klkurz.com>.
>> EL expressions use the same syntax for variable references that
>> JavaScript
>> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and
>> "#{foo['bar']}"
>> are all equivalent.
If they are equivalent, then why didn't his original syntax work? I've
seen the pattern you suggested used in the Tomahawk examples and
elsewhere, but I never knew why it was necessary.
Regards.
Jeff Bischoff
Kenneth L Kurz & Associates, Inc.
Mick Knutson wrote:
> <h:outputText value="#{messages['label.firstName']}"/>
>
> This worked great, and I don't have to change all my Resource Bundles now.
>
> Thank you so much!!!
>
>
>
> On 10/31/06, Craig McClanahan <cr...@apache.org> wrote:
>>
>>
>>
>> On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
>> >
>> > I solved the issue, but am not happy with it.
>> > It seems that using a dot notation in the Resource Bundle is not
>> > allowed.
>>
>>
>> Hold up a sec on the changes!
>>
>> EL expressions use the same syntax for variable references that
>> JavaScript
>> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and
>> "#{foo['bar']}"
>> are all equivalent.
>>
>> This gives me the error:
>> > <h:outputText value="#{messages.label.firstName}" />:
>>
>>
>> Try this instead:
>>
>> <h:outputText value="#{messages['label.firstName']}"/>
>>
>> Craig
>>
>> This does not:
>> > <h:outputText value="#{messages.label_firstName}" />:
>> >
>> > But I had to change my messages.properties declaration from:
>> > label.firstName=First Name
>> >
>> > to:
>> >
>> > label_firstName=First Name
>> >
>> >
>> >
>> >
>> >
>> >
>> > On 10/31/06, Mick Knutson < mickknutson@gmail.com> wrote:
>> > >
>> > > What is the UserBackingBeanBeanInfo ???
>> > >
>> > > All I have is a simple UserBackingBeanBean with a set/get for public
>> > > User
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > On 10/31/06, Simon Kitching <si...@rhe.co.nz> wrote:
>> > > >
>> > > > Well,everything does seem to be right. However the original
>> > > > exception
>> > > > does say:
>> > > >
>> > > > javax.faces.el.PropertyNotFoundException: Bean: java.lang.String ,
>> > > > property: firstName
>> > > > at
>> > > > org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor (
>> > > > PropertyResolverImpl.java:483)
>> > > >
>> > > > which seems to imply that getUser has returned a String object.
>> > > >
>> > > > The PropertyResolverImpl code is:
>> > > > public static PropertyDescriptor getPropertyDescriptor(
>> > > > BeanInfo beanInfo, String propertyName)
>> > > > {
>> > > > PropertyDescriptor[] propDescriptors =
>> > > > beanInfo.getPropertyDescriptors();
>> > > >
>> > > > if (propDescriptors != null)
>> > > > {
>> > > > // TODO: cache this in classLoader safe way
>> > > > for (int i = 0, len = propDescriptors.length; i < len;
>> > > > i++)
>> > > > {
>> > > > if
>> > > > (propDescriptors[i].getName().equals(propertyName))
>> > > > return propDescriptors[i];
>> > > > }
>> > > > }
>> > > >
>> > > > throw new PropertyNotFoundException("Bean: "
>> > > > + beanInfo.getBeanDescriptor().getBeanClass().getName()
>> > > > + ", property: " + propertyName);
>> > > > }
>> > > >
>> > > >
>> > > > You don't happen to have a UserBackingBeanBeanInfo class around do
>> > > > you?
>> > > >
>> > > > As a wild guess, is the User class public? Maybe if it isn't, then
>> > > > something in the java introspection or JSF el code is calling
>> > > > toString
>> > > > on it to convert it to something that is accessable..
>> > > >
>> > > > I can't think what else might be causing your issue..
>> > > >
>> > > > Cheers,
>> > > >
>> > > > Simon
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > >
>> > > Thanks
>> > >
>> > > DJ MICK
>> > > http://www.djmick.com
>> > > http://www.myspace.com/mickknutson
>> > >
>> >
>> >
>> >
>> > --
>> >
>> > Thanks
>> >
>> > DJ MICK
>> > http://www.djmick.com
>> > http://www.myspace.com/mickknutson
>>
>>
>>
>
>
Re: Solved, but not happy with solution Re: question about BackingBeans and POJO's
Posted by Mick Knutson <mi...@gmail.com>.
<h:outputText value="#{messages['label.firstName']}"/>
This worked great, and I don't have to change all my Resource Bundles now.
Thank you so much!!!
On 10/31/06, Craig McClanahan <cr...@apache.org> wrote:
>
>
>
> On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
> >
> > I solved the issue, but am not happy with it.
> > It seems that using a dot notation in the Resource Bundle is not
> > allowed.
>
>
> Hold up a sec on the changes!
>
> EL expressions use the same syntax for variable references that JavaScript
> expressions do. Thus, "#{ foo.bar}" and "#{foo[bar]}" and "#{foo['bar']}"
> are all equivalent.
>
> This gives me the error:
> > <h:outputText value="#{messages.label.firstName}" />:
>
>
> Try this instead:
>
> <h:outputText value="#{messages['label.firstName']}"/>
>
> Craig
>
> This does not:
> > <h:outputText value="#{messages.label_firstName}" />:
> >
> > But I had to change my messages.properties declaration from:
> > label.firstName=First Name
> >
> > to:
> >
> > label_firstName=First Name
> >
> >
> >
> >
> >
> >
> > On 10/31/06, Mick Knutson < mickknutson@gmail.com> wrote:
> > >
> > > What is the UserBackingBeanBeanInfo ???
> > >
> > > All I have is a simple UserBackingBeanBean with a set/get for public
> > > User
> > >
> > >
> > >
> > >
> > >
> > > On 10/31/06, Simon Kitching <si...@rhe.co.nz> wrote:
> > > >
> > > > Well,everything does seem to be right. However the original
> > > > exception
> > > > does say:
> > > >
> > > > javax.faces.el.PropertyNotFoundException: Bean: java.lang.String ,
> > > > property: firstName
> > > > at
> > > > org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor (
> > > > PropertyResolverImpl.java:483)
> > > >
> > > > which seems to imply that getUser has returned a String object.
> > > >
> > > > The PropertyResolverImpl code is:
> > > > public static PropertyDescriptor getPropertyDescriptor(
> > > > BeanInfo beanInfo, String propertyName)
> > > > {
> > > > PropertyDescriptor[] propDescriptors =
> > > > beanInfo.getPropertyDescriptors();
> > > >
> > > > if (propDescriptors != null)
> > > > {
> > > > // TODO: cache this in classLoader safe way
> > > > for (int i = 0, len = propDescriptors.length; i < len;
> > > > i++)
> > > > {
> > > > if
> > > > (propDescriptors[i].getName().equals(propertyName))
> > > > return propDescriptors[i];
> > > > }
> > > > }
> > > >
> > > > throw new PropertyNotFoundException("Bean: "
> > > > + beanInfo.getBeanDescriptor().getBeanClass().getName()
> > > > + ", property: " + propertyName);
> > > > }
> > > >
> > > >
> > > > You don't happen to have a UserBackingBeanBeanInfo class around do
> > > > you?
> > > >
> > > > As a wild guess, is the User class public? Maybe if it isn't, then
> > > > something in the java introspection or JSF el code is calling
> > > > toString
> > > > on it to convert it to something that is accessable..
> > > >
> > > > I can't think what else might be causing your issue..
> > > >
> > > > Cheers,
> > > >
> > > > Simon
> > > >
> > >
> > >
> > >
> > > --
> > >
> > > Thanks
> > >
> > > DJ MICK
> > > http://www.djmick.com
> > > http://www.myspace.com/mickknutson
> > >
> >
> >
> >
> > --
> >
> > Thanks
> >
> > DJ MICK
> > http://www.djmick.com
> > http://www.myspace.com/mickknutson
>
>
>
--
Thanks
DJ MICK
http://www.djmick.com
http://www.myspace.com/mickknutson
Re: Solved, but not happy with solution Re: question about BackingBeans and POJO's
Posted by Craig McClanahan <cr...@apache.org>.
On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
>
> I solved the issue, but am not happy with it.
> It seems that using a dot notation in the Resource Bundle is not allowed.
Hold up a sec on the changes!
EL expressions use the same syntax for variable references that JavaScript
expressions do. Thus, "#{foo.bar}" and "#{foo[bar]}" and "#{foo['bar']}"
are all equivalent.
This gives me the error:
> <h:outputText value="#{messages.label.firstName}" />:
Try this instead:
<h:outputText value="#{messages['label.firstName']}"/>
Craig
This does not:
> <h:outputText value="#{messages.label_firstName}" />:
>
> But I had to change my messages.properties declaration from:
> label.firstName=First Name
>
> to:
>
> label_firstName=First Name
>
>
>
>
>
>
> On 10/31/06, Mick Knutson <mi...@gmail.com> wrote:
> >
> > What is the UserBackingBeanBeanInfo ???
> >
> > All I have is a simple UserBackingBeanBean with a set/get for public
> > User
> >
> >
> >
> >
> >
> > On 10/31/06, Simon Kitching <si...@rhe.co.nz> wrote:
> > >
> > > Well,everything does seem to be right. However the original exception
> > > does say:
> > >
> > > javax.faces.el.PropertyNotFoundException: Bean: java.lang.String ,
> > > property: firstName
> > > at
> > > org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor (
> > > PropertyResolverImpl.java:483)
> > >
> > > which seems to imply that getUser has returned a String object.
> > >
> > > The PropertyResolverImpl code is:
> > > public static PropertyDescriptor getPropertyDescriptor(
> > > BeanInfo beanInfo, String propertyName)
> > > {
> > > PropertyDescriptor[] propDescriptors =
> > > beanInfo.getPropertyDescriptors();
> > >
> > > if (propDescriptors != null)
> > > {
> > > // TODO: cache this in classLoader safe way
> > > for (int i = 0, len = propDescriptors.length; i < len;
> > > i++)
> > > {
> > > if (propDescriptors[i].getName().equals(propertyName))
> > > return propDescriptors[i];
> > > }
> > > }
> > >
> > > throw new PropertyNotFoundException("Bean: "
> > > + beanInfo.getBeanDescriptor().getBeanClass().getName()
> > > + ", property: " + propertyName);
> > > }
> > >
> > >
> > > You don't happen to have a UserBackingBeanBeanInfo class around do
> > > you?
> > >
> > > As a wild guess, is the User class public? Maybe if it isn't, then
> > > something in the java introspection or JSF el code is calling toString
> > >
> > > on it to convert it to something that is accessable..
> > >
> > > I can't think what else might be causing your issue..
> > >
> > > Cheers,
> > >
> > > Simon
> > >
> >
> >
> >
> > --
> >
> > Thanks
> >
> > DJ MICK
> > http://www.djmick.com
> > http://www.myspace.com/mickknutson
> >
>
>
>
> --
>
> Thanks
>
> DJ MICK
> http://www.djmick.com
> http://www.myspace.com/mickknutson