简体   繁体   中英

JSF/Primefaces - XHTML in JAR and Spring

I've been working on a web application that loads some xhtml files inside a jar. With this, I didn't have any problems.
I placed a faces-config.xml in each jar, placed the corresponding xhtml files and everything was working flawlessly with a customResourceResolver that does the search in the classpath. The problem came up when I added Spring into the equation, as the following example shows:

<managed-bean>
    <managed-bean-name>entityController</managed-bean-name>
    <managed-bean-class>com.test.EntityController</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
        <property-name>client</property-name>
        <value>#{client}</value>
    </managed-property>
</managed-bean>

Where client is an entity inside the Spring context.

I already have configured the corresponding listeners and web.xml for Spring, and for all the managed beans contained in the WAR the injection is working.

No error is being thrown at startup, and all the Spring beans are getting properly loaded. However, when I invoke the method of the managed bean that's contained in the jar, which has to access the managed property, I find that the property was not injected.

Am I missing something?

Let me know if further information is required.

Thanks a lot in advance!

Been able to sort it out using JSF annotations instead of the configuration in faces-config.xml.

So my managed bean ended up pretty much like this one:

@ManagedBean(name="entityController")  
@SessionScoped
public class EntityController {

   @ManagedProperty("#{client}")
   private Client client;

Thanks everyone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM