Re: Static method
Probably a better way to handle this is just to use a setter to set the
value of valor.
public class BeanWrapper {
private int valor;
public static void setValor( int v )
{
valor = v;
}
public static List createBeanCollection()
{
return miDao.onbtenObjectosPorId( valor );
}
}
but with this code you will get an "non-static variable valor cannot
be referenced from a static context" so this wont work.
Now this is a tad dangerous, you'll get issues with concurrency and
what-not. But it might suit your needs.
yes in fact i was thinking in sincronized code in the method that
calls this class.
Have you considered a non-static method? It seems to me that would solve
a lot more problems. You could also inject a non-static object into the
wrapper class.
the problem is that this is the signature a must use. i cant rewrite
it to "public List mimethod()" this is an ibatis requirementin order
to populate a report whit objects instead of using an sql data source.
public class BeanWrapper {
private Beans b;
public static void setValor( Beans v )
{
b = v;
}
public static List createBeanCollection()
{
return b.onbtenObjectosPorId();
}
}
yes it souns fine. but the problem is the same i mentioned above.
where a Beans object has the "valor" injected into it, ie.,
setValor( new Beans( 1 ) );
Now you also have a fully constructed object that you can synchronize
on, for example. And it's private, so no one else can call it but your
createBeanCollection() method.
thank you for your time.