Magazine
 
Integrating JSF, Spring and Hibernate
 

public static Object findBean(String
beanName){
FacesContext context=
FacesContext.getCurrentInstance();
ServletContext servletContext =
(ServletContext)context.getExternalContext().
getContext();
ApplicationContext appContext =
WebApplicationContextUtils.
getWebApplicationContext(servletContext);
Object o =appContext.getBean(beanName);
return o;
}
}

The findBean() method of ServiceFinder class is used to get the reference of in the backing beans of JSF.

10. JSF, Integrating Presentation Layer In this section we will learn about configuring the presentation layer.
The presentation tier integration actually involves the following steps:

1. Creating JSP pages
The JSP pages used in this application are login.jsp, registration.jsp, successLogin.jsp and welcome.jsp. These pages are already described in the previous section Developing Login and Registration form and backing beans.

2. Defining the page navigation rules
Following code present in the faces-config.xml file defines the page navigation rule.

<navigation-rule>
<from-view-id>/pages/login.jsp</fromview-
id>
<navigation-case>
<from-outcome>reg</from-outcome>
<to-view-id>/pages/
registration.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>success</fromoutcome>
<to-view-id>/pages/

 

successLogin.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</fromoutcome>
<to-view-id>/pages/login.jsp</toview-
id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/pages/
registration.jsp</from-view-id>
<navigation-case>
<from-outcome>success</fromoutcome>
<to-view-id>/pages/
welcome.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</fromoutcome>
<to-view-id>/pages/
registration.jsp</to-view-id>
</navigation-case>
</navigation-rule>

3. Developing and configuring backing beans

In our application there are two backing beans Bean and CheckValidUser. Following code in the faces-config.xml file declares the backing beans:

<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<messagebundle>
net.roseindia.web.ui.messages
</message-bundle>
</application>
<managed-bean>
<managed-bean-name>Bean</managedbean-
name>
<managed-beanclass>
net.roseindia.web.ui.Bean
</managed-bean-class>
<managed-bean-scope>session
</managed-bean-scope>
</managed-bean>

Jan 2008 | Java Jazz Up | 72
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

83, 84 , 85 , 86, 87 , 88, 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103, 104 , 105 ,

106, 107,

Download PDF