KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > faces > PageFlowApplicationFactory


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.pageflow.faces;
19
20 import org.apache.beehive.netui.util.logging.Logger;
21 import org.apache.beehive.netui.pageflow.faces.internal.PageFlowApplication;
22
23 import javax.faces.application.ApplicationFactory;
24 import javax.faces.application.Application;
25
26 /**
27  * JavaServer Faces application factory that enables Page Flow integration. It is activated like this in
28  * faces-config.xml:
29  * <blockquote>
30  * <code>
31  * &lt;factory&gt;<br/>
32  * &nbsp;&nbsp;&nbsp;&nbsp;&lt;application-factory&gt;org.apache.beehive.netui.pageflow.faces.PageFlowApplicationFactory&lt;/application-factory&gt;<br/>
33  * &lt;/factory&gt;
34  * </code>
35  * </blockquote>
36  *
37  * JSF/Page Flow integration has the following features:
38  * <ul>
39  * <li>
40  * A JSF component like CommandLink or CommandButton can raise a Page Flow action simply by specifying the
41  * action name in its <code>action</code> attribute, like this:
42  * <blockquote>
43  * <code>
44  * &lt;h:commandLink action="someAction" value="raise a Page Flow action"/&gt;
45  * </code>
46  * </blockquote>
47  * The component can send a form bean to the action by adding a "submitFormBean" attribute with a binding
48  * expression that will determine the bean instance:
49  * <blockquote>
50  * <code>
51  * &lt;h:commandLink action="someAction" value="submit a form bean to a Page Flow action"&gt;<br/>
52  * &nbsp;&nbsp;&nbsp;&nbsp;&lt;f:attribute name="submitFormBean" value="backing.theForm"/&gt;<br/>
53  * &lt;/h:commandLink&gt;
54  * </code>
55  * </blockquote>
56  * In the example above, the value returned from the backing bean's <code>getTheForm</code> method will be
57  * sent to the "someAction" action in the page flow.
58  * </li>
59  * <li>
60  * A {@link org.apache.beehive.netui.pageflow.FacesBackingBean} instance will be created whenever a
61  * corresponding JSF path is requested (e.g., an instance of FacesBackingBean-derived foo.MyPage will be created
62  * for the webapp-relative path "/foo/MyPage.faces"). The instance will be released (removed from the user
63  * session) when a non-matching path is requested. A faces backing bean can hold component references and
64  * event/command handlers, and it can raise actions with normal JSF command event handlers that are annotated
65  * with {@link org.apache.beehive.netui.pageflow.annotations.Jpf.CommandHandler &#64;Jpf.CommandHandler}.
66  * The bean instance can be bound to with a JSF-style expression like <code>#{backing.myComponent}</code>.
67  * </li>
68  * <li>
69  * When a Page Flow action goes back to a JSF page through the <code>currentPage</code> or
70  * <code>previousPage</code> values for
71  * {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Forward#navigateTo navigateTo}
72  * on {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Forward &#64;Jpf.Forward}, the page's backing
73  * bean and component tree are restored.
74  * </li>
75  * </ul>
76  */

77 public class PageFlowApplicationFactory
78         extends ApplicationFactory
79 {
80     private static final Logger _log = Logger.getInstance( PageFlowApplicationFactory.class );
81     
82     private ApplicationFactory _delegate;
83     private PageFlowApplication _app;
84     
85     public PageFlowApplicationFactory( ApplicationFactory delegate )
86     {
87         if ( _log.isDebugEnabled() )
88         {
89             _log.debug( "Adapting ApplicationFactory" + delegate );
90         }
91         
92         _delegate = delegate;
93         _app = new PageFlowApplication( delegate.getApplication() );
94     }
95     
96     public Application getApplication()
97     {
98         return _app;
99     }
100
101     public void setApplication( Application application )
102     {
103         _delegate.setApplication( application );
104         _app = new PageFlowApplication( application );
105     }
106 }
107
Popular Tags