Hello,
  here's the config file that i am using
- i have a bunch of 'spring-only' xml file that configures some background spring tasks that i am using (for quartz, acegi, hibernate and my persistence layer)

- i have 1 jsf-spring config file which contains spring-managed-bean that i am using ALSO as jsf-beans
- i have a faces-managed-beans which configures JSF beans (which inject or not jsf-spring managed beans)

the number of config files really depends on how you split your configuration files
surely, i could just have had 2 gigantic config files, one for spring and another for JSF, but i decided to:
- split spring config files depending on their functionality (i have, for example, a web-context.xml, quartz-context.xml, acegi-security.xml and so on)
- split jsf config files in   faces-config.xml, faces-managed-beans.xml , faces-navigation.xml

On 4/2/06, Philippe Lamote <[EMAIL PROTECTED]> wrote:
Hi Marco, 
I have quickly looked at it, but the exampe-ZIP provided with it, issues such a bunch of configuration files that my initial enthusiasm quickly cooled off. :-(
So, 
1/ What would it take to use this (apart from adding the lib in web-inf/lib :-) (if you don't mind, could you make a summary as I did for the Spring - JSF integration? I've seen the question pass by on this list but nowhere a consise, clear stepwise approach for this integration. Also there is a strange total lack of doc of this Sourceforge project)

i did it above.. hope it was e nough.. yes, i know docs are not much.. but sometimes you have just to try and find out what's missing etc ...  :(
 
2/ What added value does it have compared to regular integration? (i.e. what can I do more?)

cant say for sure.. when i googled jsf-spring  at the time when i needed to integrate the two, i got first hit as jsf-spring config library.. it worked fine and i just keep on using it...

 

 & Another question: what effect would it have (current setup) if I add to my Spring config, the classes used as JSF beans? Which injection would happen first? And would it have any side effects?

injection should depend on dependencies (if im correct).. so if you have 5 jsf beans that dont depend at all to spring beans, you shouldnt be concerned to which gets loaded first... when your app will have started, if no config mistakes were done, then you will have all your beans

if you have 5 jsf beans that depends on spring beans, then obviously spring beans will be loaded before your jsf beans..
 
>Currently I only have JSF beans having managed props in the faces-config.xml, not the >other way around.


ok let me tell you a concrete example i am using

i have a serviceLocator bean that depends on some other spring beans. i have 3 jsf beans that depends on the serviceLocator bean

i have declared the serviceLocator bean in my spring files, and i have referred it as a managed property in my faces-managed-beans.xml. jsf-spring config did the rest... and at runtime code works just fine...

i have crfeated a faces-context.xml fiel that contains spring beans taht will need to be referred from jsf manage dbeans
but again, i didnt need to craete ana dditional faces-context.xml, could have declared my serviceLocator  in the spring files

to summarize, if you want to use a jsf bean as spring managed, you hsould declare it in your spring files....
if you want to have a jsf managed beans that uses a spring bean as managed property, then declare your jsf bean in your faces configuration files.... jsf-spring will take care of injection..

hth
 marco





Thanks, 
Philippe

On 02 Apr 2006, at 17:35, Marco Mistroni wrote:

Hello,
  you might want to try jsf-spring project (it's a sourceforge project), it integrates the two framework just fine
i m currently using it, and it work just fine

hth
 marco

On 4/2/06, Philippe Lamote < [EMAIL PROTECTED]> wrote:
Hi List,

I'm getting unexplainable MyFaces-Spring integration problems, I was
hoping someone could give a hint.

1/ First some setup info: I followed the Sping & JSF doc and did this
to integrate the two: (I will try to be being extensive as big errors
often small roots...)

1.1 Libs were added (in web-inf/lib of course; spring.jar & spring-
web.jar) Tools I use are: Eclipse 3.2, WTP plugin, Tomcat 5.12 and
Spring 1.2
1.2 web.xml features:

<context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <context-param>
       <param-name>log4jConfigLocation</param-name>
       <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>

<context-param>
        <param-name> javax.faces.CONFIG_FILES</param-name>
         <param-value>/WEB-INF/faces-config.xml</param-value>
     </context-param>

... and:

  <listener>
       <listener-
class>org.apache.myfaces.webapp.StartupServletContextListener</
listener-class>
   </listener>

... and:

   <listener>
          <listener-
class> org.springframework.web.util.Log4jConfigListener </listener-class>
    </listener>

       <listener>
          <listener-
class>org.springframework.web.context.ContextLoaderListener </listener-
class>
       </listener>

1.3 faces-config file features:

<application>
         <variable-resolver>
               org.springframework. web.jsf.DelegatingVariableResolver
         </variable-resolver>


         <locale-config>
             <default-locale>fr</default-locale>
             <supported-locale>nl</supported-locale>
           <supported-locale>en</supported-locale>
         </locale-config>
</application>
.... and an exampe how the JSF Managed beans are declared in this
faces-config.xml with Spring Managed beans: ("webfacade" is a Spring
Managed bean, cf Sping config file further)

<managed-bean>
                <managed-bean-name>managerbean</managed-bean-name>
                <managed-bean-class>be.mnemonica. web.beans.ManagerBean</managed-
bean-class>
                <managed-bean-scope>session</managed-bean-scope>
                <managed-property>
                        <property-name>facade</property-name>
                        <value>#{webfacade}</value>
                </managed-property>
</managed-bean>

1.4 Sping applicationContext.xml: (extrait)

<bean id="jdo2Persistor"
class="be.mnemonica.persistence.JDO2PersistenceDelegator " >
        <property name="modelPackageName">
                <description> The name of the package where the model classes of
the application reside, for which this Persistence Delegator is
written) </description>
                <value>be.mnemonica.model</value>
        </property>
        <property name="appMgr"><ref local="appmgr"/></property>

</bean>

<bean id="webfacade" class="be.mnemonica.client.WebFacade">
        <property name="persistor">
                <description>The Persistor Delegator for the Facade. </description>
                <ref local="jdo2Persistor"/>
        </property>
</bean>

The idea is: this WebFacade is used by all JSF Managed beans to
delegate calls to the proper Delegator ( e.g. CRUD Model-related calls
are delegated to the PersistenceDelgatorInterface - I have Sping
inject this Interface with a JDO2 Implementation implementing this
Interface.

Just to be explicit:
        I have NOT declared my Spring beans as JSF manage beans (should I?)
        I don't inject any Spring Managed bean with a JSF Managed bean

2/ Yet, the problems I'm having are substantial.
The JSF Managed beans just DON'T seem to be injected with
Sping-"filled" instances (the supposedly injected values are null)
E.g. in the case above, "modelPackageName" remained "null".
I could solve some issues by putting in all the JSF Managed beans'
Constructors: (e.g. in this JSF managerbean)
        ApplicationContext ctx = FacesContextUtils.getWebApplicationContext
(FacesContext.getCurrentInstance());
        facade = (WebFacade)ctx.getBean("webfacade");

Yet of course this is a pity; I'm hardwiring again & creating
explicit dependancies to Spring. (which is... the opposite of why I
turned to Spring in the first place!! :-))

--> Anyone else had issues like this? (or did I forget smth?)
Or, even if not, any genious idea how to make this work properly? (a
lesser genius idea that works will be admired as well ;-)

  & Just to make sure I get the sequence right, is it correct that
this is the mechanism:
By these settings, every time a JSF Managed bean creates a JSF bean,
Spring intervenes and injects (in cascade) the configured properties. So
JSF bean creation USES Spring pre-configured Properties.
Last and least (small sub question) I haven't noticed a difference
when I leave the MyFaces 's "StartupServletContextListener" in, or
out the web.xml. --> Is it necessary?!

Thanks,
Philippe








Reply via email to