user124722
user124722

Reputation:

JSF 1.2 + Spring 2.5. How to?

I am using Spring to manage my DAO & Services. And JSF for UI. I want to use dependency injection in my JSF backing-bean. There is an article that explained how I can do that.

But I have two separate projects: one for Service and one for UI. The Spring configuration file is located in Service project.

How can I connect both project with Spring? I want to annotate my JSF pages for DI.

Upvotes: 1

Views: 2931

Answers (4)

user124722
user124722

Reputation:

I find some solution one: Sample Application using JSF, Spring 2.5, and Java Persistence APIs with Glassfish v2 . But I have problem with it.

I can post this problem hear or must create new topic? Sorry for stupid question, i'm newbie her.

Upvotes: 0

user124722
user124722

Reputation:

Thank for everyone I did it. My mistake was with bean initialization. I tried to access my injected bean in constructor, but must must did in @PostConstruct method. And all that time i tried to find mistake in my config file. But it was in such simply place :)

Upvotes: 0

JARC
JARC

Reputation: 5328

You can achieve this by using Spring Web Flow.

Spring have examples which show:

  1. A JSF centric approach where your Spring and JSF beans are managed/configured the JSF way (faces-config) and a
  2. Spring centric approach where your beans (including ManagedBeans) are managed in the Spring Context.

See Spring Flow Web Home

Upvotes: 1

duffymo
duffymo

Reputation: 308733

If you mean that you have one WAR with web services defined in it, and another separate WAR with the JSF stuff, I think it's really two separate projects each with their own Spring configuration.

The web service WAR will use either Spring web services or perhaps HTTP remoting to expose your service interfaces to clients via HTTP. This will have one set of application context configuration, either XML or annotations.

The JSF WAR will have the JSPs and controllers. The controllers will be injected with clients that will interact with the remote services to accomplish what you wish. That's all they need to know about the service WAR. There doesn't need to be any duplication of configuration at all.

It's actually a nice design, because it completely decouples the view from the rest of the problem.

Upvotes: 0

Related Questions