Kurt Edegger wrote:
Hi,
I wonder if it is possible to declare the constructor of a bean in
faces-config.xml similar to using <constructor-arg> in spring's
configuration files.
This is definitely not a feature of the JSF specification, and MyFaces
can't add any new tags to the faces-config.xml file without violating
the spec.
The idea behind this is, that I'd like to inject a bean into my
application and use a referenced bean already in the constructor.
As far as I know and encountered, first the default constructor is
called, then the referenced beans are injected by using the
corresponding setters, and finally the bean is used in the application
depending of the scope.
There's no way to set anything in the constructor AFAIK.
The constructor could manually look up the desired object, though: see
the FAQ entry "How can I access one Managed Bean from another?".
You can also do initialisation after all the properties have been set.
See the FAQ entry "How do I know when a managed bean's properties have
all been set?".
http://wiki.apache.org/myfaces/FAQ
Or is possible to use/reference Spring beans in faces-config.xml?
Any managed-property like:
<managed-property>
<name>foo</name>
<value>#{someValue}</value>
</managed-property>
simply looks for a key "someValue" in the request, session and
application scopes. So if your spring bean is stored in one of those
maps then it will be passed to the managed bean on creation.
Regards,
Simon