You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rogerio Pereira <ro...@gmail.com> on 2006/05/26 19:21:34 UTC
advice about dependency injection
I have 3 beans: beanA, beanB and beanC.
Both beanA and beanB uses beanB (ArrayList), from beanA i only remove itens
from beanB and from beanC i add, get and set a item in beanB.
Everything is ok when beanC to these operations on beanB but if i try to
remove an item from beanA i'm getting an IndexOutOfBoundsException.
Note: i'm using saveState in beanA
I'm following this wiki entry:
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
Please somebody help me.
--
Yours truly (Atenciosamente),
Rogério
Re: advice about dependency injection
Posted by Rogerio Pereira <ro...@gmail.com>.
I put the code beanB.size() >= myTable.getRowIndex() before remove the item
and now the item in ArrayList is never being removed.
2006/6/1, James Richards <ja...@northps.com>:
>
> The example isn't very clear but based on the below
>
> public void removeItem(ActionEvent event)
> {
> beanB.remove(myDataTable.getRowIndex());
> return null;
> }
>
> Have you tried catching IndexOutOfBoundsException in the above
> method? Also, why return null? In any case, I would have an if (
> beanB.size() >= myTable.getRowIndex()) or so to prevent any such problems.
>
> Hope that helps,
>
> James
>
> -----Original Message-----
> From: Rogerio Pereira [mailto:rogerio.araujo@gmail.com]
> Sent: Thu 6/1/2006 1:44 PM
> To: MyFaces Discussion
> Subject: Re: advice about dependency injection
>
> Any sugestions?
>
>
> I have 3 beans: beanA, beanB and beanC.
> >
> > Both beanA and beanB uses beanB (ArrayList), from beanA i only remove
> > itens from beanB and from beanC i add, get and set a item in beanB.
> >
> > Everything is ok when beanC to these operations on beanB but if i try to
> > remove an item from beanA i'm getting an IndexOutOfBoundsException.
> >
> > Note: i'm using saveState in beanA
> >
> > I'm following this wiki entry:
> >
> > http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
> >
> > I have full details here:
> >
> > http://issues.apache.org/jira/browse/MYFACES-1312
> >
>
>
>
--
Yours truly (Atenciosamente),
Rogério
RE: advice about dependency injection
Posted by James Richards <ja...@northps.com>.
The example isn't very clear but based on the below
public void removeItem(ActionEvent event)
{
beanB.remove(myDataTable.getRowIndex());
return null;
}
Have you tried catching IndexOutOfBoundsException in the above method? Also, why return null? In any case, I would have an if (beanB.size() >= myTable.getRowIndex()) or so to prevent any such problems.
Hope that helps,
James
-----Original Message-----
From: Rogerio Pereira [mailto:rogerio.araujo@gmail.com]
Sent: Thu 6/1/2006 1:44 PM
To: MyFaces Discussion
Subject: Re: advice about dependency injection
Any sugestions?
I have 3 beans: beanA, beanB and beanC.
>
> Both beanA and beanB uses beanB (ArrayList), from beanA i only remove
> itens from beanB and from beanC i add, get and set a item in beanB.
>
> Everything is ok when beanC to these operations on beanB but if i try to
> remove an item from beanA i'm getting an IndexOutOfBoundsException.
>
> Note: i'm using saveState in beanA
>
> I'm following this wiki entry:
>
> http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
>
> I have full details here:
>
> http://issues.apache.org/jira/browse/MYFACES-1312
>
Re: advice about dependency injection
Posted by Rogerio Pereira <ro...@gmail.com>.
Any sugestions?
I have 3 beans: beanA, beanB and beanC.
>
> Both beanA and beanB uses beanB (ArrayList), from beanA i only remove
> itens from beanB and from beanC i add, get and set a item in beanB.
>
> Everything is ok when beanC to these operations on beanB but if i try to
> remove an item from beanA i'm getting an IndexOutOfBoundsException.
>
> Note: i'm using saveState in beanA
>
> I'm following this wiki entry:
>
> http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
>
> I have full details here:
>
> http://issues.apache.org/jira/browse/MYFACES-1312
>
Re: advice about dependency injection
Posted by Murat Hazer <mu...@gmail.com>.
hi rogerio,
this is your second message with same text, i think you should describe your
problem more clearly, and give a piece of real java code...
regards...
On 5/26/06, Rogerio Pereira <ro...@gmail.com> wrote:
>
> I have 3 beans: beanA, beanB and beanC.
>
> Both beanA and beanB uses beanB (ArrayList), from beanA i only remove
> itens from beanB and from beanC i add, get and set a item in beanB.
>
> Everything is ok when beanC to these operations on beanB but if i try to
> remove an item from beanA i'm getting an IndexOutOfBoundsException.
>
> Note: i'm using saveState in beanA
>
> I'm following this wiki entry:
>
> http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother
>
>
> Please somebody help me.
>
> --
> Yours truly (Atenciosamente),
>
> Rogério
>
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/