Anton Gavazuk schrieb:
All necessary beans will be instantiated automatically by JSF as long as you
define them in your faces-config.xml file.
its clear,
but I want to put some business related info in bean before showing them.
like following
JSF method {
  SomeBean = new SomeBean();
  SomeBean.value1 =     Service.getSomething();
  SomeBean.value2 =     Service.getSomething();

  SomeBean2 = new SomeBean2();
.....
 //now I can add these beans to faces context of course, but maybe
there is another way?
}

I dont want to call business functions inside getters of managed beans.

If any class should be initialised before use, then the normal place to do that is in the class constructor.

If you need to have some values injected into your bean first, then unfortunately the constructor cannot be used as faces-config.xml does not support injecting of constructor-args. In that case, you can: * use a better dependency-injection framework like Spring (spring can be used with JSF) * use the @PostConstruct annotation to mark some method that should be called after injection is complete (but unfortunately there is a bug in myFaces that means this doesn't currently work) * rely on the fact that injection always occurs in the order listed in the faces-config.xml file.

Regards,
Simon

Reply via email to