|
JSF Application |
<h:commandButton action=”result”
value=”#{message.button_text}” />
Here action attribute is set to “result”. When user presses the command button then which page will be displayed is determined by the navigation rule defined in faces-config.xml configuration file. This rule has been defined like this for our application:
<navigation-rule>
<from-view-id>/pages/inputname.jsp</
from-view-id>
<navigation-case>
<from-outcome>result</fromoutcome>
<to-view-id>result.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule> defines navigation rule. <from-view-id> is used to specify the jsp file for which navigation rule is to be defined. Here in our application it is inputname.jsp that is in pages folder. <navigation-case> specifies the value which is matched with the value specified in action attribute of commandButton tag. If it matches then the page specified within <toview- id> tag is displayed. Here in our application it is “result.jsp”.
So after editing faces-config.xml file, it will look like following:
<?xml version=”1.0"?>
<!DOCTYPE faces-config PUBLIC
“-//Sun Microsystems, Inc.//DTD JavaServer
Faces Config 1.1//EN”
“http://java.sun.com/dtd/webfacesconfig_
1_1.dtd”>
<faces-config>
<managed-bean>
<managed-beanname>
StoreNameBean</managed-beanname>
<managed-bean-class>
javajazzup.PersonBean</managed-beanclass>
<managed-bean-scope>request</
| |
managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/
inputname.jsp</from-view-id>
<navigation-case>
<from-outcome>result</fromoutcome>
<to-view-id>result.jsp</to-viewid>
</navigation-case>
</navigation-rule>
</faces-config>
Editing web.xml:
The “FacesServlet” servlet handles JSF
applications. So as we are using JSF
framework in our web application, we will edit
the deployment descriptor file web.xml to
define “FaceServlet” and its mapping in
web.xml file.
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servletclass>
javax.faces.webapp.FacesServlet</
servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!— Faces Servlet Mapping —>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet> element maps the “javax.faces.webapp.FacesServlet” servlet
class to a symbolic name i.e. Faces Servlet is
an alias for “javax.faces.webapp.FacesServlet”
servlet .<servlet-mapping> element is used
to map any request of pattern like .jsf in the
URL must be passed to the Faces servlet. The FacesServlet servlet works as an engine
for all JSF applications( handling of all JSF related
requests, building component tree of the JSP
page, accessing all JSP pages in the application,
creating an Event object and passing it to any
registered listener). So all requests that need |
|
|
Oct 2007 | Java Jazz Up |60 |
|
|
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,
Download PDF |
|
|
|
|
|
|
|
|
|