KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > jsfext > event > handlers > RequestAttributeOutputType


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.tools.jsfext.event.handlers;
24
25
26 /**
27  * <p> This class implements the OutputType interface to provide a way to
28  * get/set Output values from a ServletRequest attribute Map.</p>
29  *
30  * @author Ken Paulsen (ken.paulsen@sun.com)
31  */

32 public class RequestAttributeOutputType implements OutputType {
33
34     /**
35      * <p> This method is responsible for retrieving the value of the Output
36      * from a Request attribute. 'key' may be null, if this occurs, a
37      * default name will be provided. That name will follow the
38      * following format:</p>
39      *
40      * <p> [handler-id]:[key]</p>
41      *
42      * @param context The HandlerContext
43      *
44      * @param outDesc The IODescriptor for this Output value in
45      * which to obtain the value
46      *
47      * @param key The optional 'key' to use when retrieving the
48      * value from the ServletRequest attribute Map.
49      *
50      * @return The requested value.
51      */

52     public Object JavaDoc getValue(HandlerContext context, IODescriptor outDesc, String JavaDoc key) {
53     if (key == null) {
54         // Provide a reasonably unique default
55
key = context.getHandlerDefinition().getId()
56         + ':' + outDesc.getName();
57     }
58
59     // Get it from the Request attribute map
60
return context.getFacesContext().getExternalContext().
61         getRequestMap().get(key);
62     }
63
64     /**
65      * <p> This method is responsible for setting the value of the Output to
66      * a ServletRequest attribute. 'key' may be null, in this case, a
67      * default name will be provided. That name will follow the
68      * following format:</p>
69      *
70      * <p> [handler-id]:[key]</p>
71      *
72      * @param context The HandlerContext
73      *
74      * @param outDesc The IODescriptor for this Output value in
75      * which to obtain the value
76      *
77      * @param key The optional 'key' to use when setting the
78      * value into the ServletRequest attribute Map
79      *
80      * @param value The value to set
81      */

82     public void setValue(HandlerContext context, IODescriptor outDesc, String JavaDoc key, Object JavaDoc value) {
83     if (key == null) {
84         // Provide a reasonably unique default
85
key = context.getHandlerDefinition().getId()
86         + ':' + outDesc.getName();
87     }
88
89     // Get it from the Request attribute map
90
context.getFacesContext().getExternalContext().
91         getRequestMap().put(key, value);
92     }
93 }
94
Popular Tags