You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Philippe Lamote <ph...@mac.com> on 2006/05/03 17:25:20 UTC
direct access to ArrayList elements by index possible?
Hi List,
Does anyone know whether it is possible to directly access the
elements of an instantiated ArrayList by their index?
So if I would have in my backing bean:
ArrayList<String> list = new ArrayList<String>() // with e.g.
elements from index [0] to [4] having precise semantics & being
instantiated in the bean constructor
--> is there a way to do, on a page, stuff like:
<h:inputText value="#{backingBean.list[2]}" />
It would avoid having to create one dedicated proxy variable per
index and handling the synchronization between these two.
Thanks for tips,
Phil
Re: direct access to ArrayList elements by index possible?
Posted by Mert Çalışkan <mc...@gmail.com>.
the list itself should be managed. Your backing bean for backingBean is
being managed in addition to this.
here is a snippet from faces-config.xml.
<managed-bean>
<managed-bean-name>backingBean</managed-bean-name>
<managed-bean-class>yourpackage.BackingBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>list</managed-bean-name>
<managed-bean-class>java.util.ArrayList</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Regards,
Mert
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
>
> ? It is a managed bean. (thought "backing bean" & "managed beans" were
> synonyms - aren't they?!)Well, donno what goes wrong then, I'll do some
> more tests.
> Thx,
> Phil
>
> On 03 May 2006, at 19:25, Mert Çalışkan wrote:
>
> Yes Phil,
>
> <h:inputText value="#{backingBean.list[2]}" /> is right.
>
> But be careful about the scope of the list. If you are using it for
> another pages make it a managed-bean.
>
> Regards,
>
> Mert
>
>
> On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
> >
> > Well, that is very nice to know :-)
> > And what would be the proper syntax for doing this?
> > The values don't seem to get updated in the backing bean, so I guess
> > there's smth wrong with my syntax... (?)
> > Phil
> >
> >
> > On 03 May 2006, at 18:26, Mert Çalışkan wrote:
> >
> > yes it is possible..
> >
> >
> > On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
> > >
> > > Hi List,
> > >
> > > Does anyone know whether it is possible to directly access the
> > > elements of an instantiated ArrayList by their index?
> > >
> > > So if I would have in my backing bean:
> > >
> > > ArrayList<String> list = new ArrayList<String>() //
> > > with e.g.
> > > elements from index [0] to [4] having precise semantics & being
> > > instantiated in the bean constructor
> > >
> > > --> is there a way to do, on a page, stuff like:
> > >
> > > <h:inputText value="#{backingBean.list [2]}" />
> > >
> > > It would avoid having to create one dedicated proxy variable per
> > > index and handling the synchronization between these two.
> > >
> > > Thanks for tips,
> > > Phil
> > >
> >
> >
> >
>
>
Re: direct access to ArrayList elements by index possible?
Posted by Philippe Lamote <ph...@mac.com>.
? It is a managed bean. (thought "backing bean" & "managed beans"
were synonyms - aren't they?!)
Well, donno what goes wrong then, I'll do some more tests.
Thx,
Phil
On 03 May 2006, at 19:25, Mert Çalışkan wrote:
Yes Phil,
<h:inputText value="#{backingBean.list[2]}" /> is right.
But be careful about the scope of the list. If you are using it for
another pages make it a managed-bean.
Regards,
Mert
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
Well, that is very nice to know :-)
And what would be the proper syntax for doing this?
The values don't seem to get updated in the backing bean, so I guess
there's smth wrong with my syntax... (?)
Phil
On 03 May 2006, at 18:26, Mert Çalışkan wrote:
yes it is possible..
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
Hi List,
Does anyone know whether it is possible to directly access the
elements of an instantiated ArrayList by their index?
So if I would have in my backing bean:
ArrayList<String> list = new ArrayList<String>() //
with e.g.
elements from index [0] to [4] having precise semantics & being
instantiated in the bean constructor
--> is there a way to do, on a page, stuff like:
<h:inputText value="#{backingBean.list [2]}" />
It would avoid having to create one dedicated proxy variable per
index and handling the synchronization between these two.
Thanks for tips,
Phil
Re: direct access to ArrayList elements by index possible?
Posted by Mert Çalışkan <mc...@gmail.com>.
Yes Phil,
<h:inputText value="#{backingBean.list[2]}" /> is right.
But be careful about the scope of the list. If you are using it for another
pages make it a managed-bean.
Regards,
Mert
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
>
> Well, that is very nice to know :-)
> And what would be the proper syntax for doing this?
> The values don't seem to get updated in the backing bean, so I guess
> there's smth wrong with my syntax... (?)
> Phil
>
>
> On 03 May 2006, at 18:26, Mert Çalışkan wrote:
>
> yes it is possible..
>
>
> On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
> >
> > Hi List,
> >
> > Does anyone know whether it is possible to directly access the
> > elements of an instantiated ArrayList by their index?
> >
> > So if I would have in my backing bean:
> >
> > ArrayList<String> list = new ArrayList<String>() // with
> > e.g.
> > elements from index [0] to [4] having precise semantics & being
> > instantiated in the bean constructor
> >
> > --> is there a way to do, on a page, stuff like:
> >
> > <h:inputText value="#{backingBean.list [2]}" />
> >
> > It would avoid having to create one dedicated proxy variable per
> > index and handling the synchronization between these two.
> >
> > Thanks for tips,
> > Phil
> >
>
>
>
Re: direct access to ArrayList elements by index possible?
Posted by Philippe Lamote <ph...@mac.com>.
Well, that is very nice to know :-)
And what would be the proper syntax for doing this?
The values don't seem to get updated in the backing bean, so I guess
there's smth wrong with my syntax... (?)
Phil
On 03 May 2006, at 18:26, Mert Çalışkan wrote:
yes it is possible..
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
Hi List,
Does anyone know whether it is possible to directly access the
elements of an instantiated ArrayList by their index?
So if I would have in my backing bean:
ArrayList<String> list = new ArrayList<String>() //
with e.g.
elements from index [0] to [4] having precise semantics & being
instantiated in the bean constructor
--> is there a way to do, on a page, stuff like:
<h:inputText value="#{backingBean.list [2]}" />
It would avoid having to create one dedicated proxy variable per
index and handling the synchronization between these two.
Thanks for tips,
Phil
Re: direct access to ArrayList elements by index possible?
Posted by Mert Çalışkan <mc...@gmail.com>.
yes it is possible..
On 5/3/06, Philippe Lamote <ph...@mac.com> wrote:
>
> Hi List,
>
> Does anyone know whether it is possible to directly access the
> elements of an instantiated ArrayList by their index?
>
> So if I would have in my backing bean:
>
> ArrayList<String> list = new ArrayList<String>() // with
> e.g.
> elements from index [0] to [4] having precise semantics & being
> instantiated in the bean constructor
>
> --> is there a way to do, on a page, stuff like:
>
> <h:inputText value="#{backingBean.list[2]}" />
>
> It would avoid having to create one dedicated proxy variable per
> index and handling the synchronization between these two.
>
> Thanks for tips,
> Phil
>