001package bradleyross.j2ee.beans;
002import java.util.Map;
003import java.io.Serializable;
004// import java.util.Enumeration;
005import javax.faces.context.FacesContext;
006//import javax.faces.context.ExternalContext;
007import javax.servlet.http.HttpSession;
008import javax.servlet.http.HttpServletResponse;
009import javax.servlet.http.HttpServletRequest;
010import javax.faces.bean.RequestScoped;
011import javax.faces.bean.ManagedBean;
012import javax.faces.bean.ManagedProperty;
013/** 
014 * Request scoped sample bean.
015 * 
016 * <p><a href="http://incepttechnologies.blogspot.com/p/jsf-implicit-objects.html" target="_blank">
017 *    JSF implicit objects can be found here.</a></p>
018 * <p><a href="http://docs.oracle.com/javaee/7/tutorial/doc/jsf-custom012.htm" target="_blank">
019 *    http://docs.oracle.com/javaee/7/tutorial/doc/jsf-custom012.htm</a></p>
020 * <p>If the bean returns a collection, the Oracle documentation says that you can get a
021 *    specific value by following it by the index in square brackets.  It also indicates that 
022 *    something similar can be done for Maps, but this may only apply to specific EL and
023 *    JSF implementations.</p>
024 * <p>It may be that the implicit beans are handled differently and aren't fully available until
025 *    after the managed beans are done with the property management.</p>
026 *    
027 * @author Bradley Ross
028 *
029 */
030@SuppressWarnings("serial")
031@ManagedBean
032@RequestScoped
033public class RequestProperties implements Serializable {
034
035        public RequestProperties() {
036                
037        }
038        /**
039         * Implicit object.
040         */
041        @ManagedProperty("#{request}")
042        protected HttpServletRequest request;
043        public HttpServletRequest getRequest() {
044                return request;
045        }
046        public void setRequest (HttpServletRequest value) {
047                request = value;
048        }
049        /**
050         * Implicit object.
051         */
052        @ManagedProperty("#{response}")
053        protected HttpServletResponse response;
054        public HttpServletResponse getResponse() {
055                return response;
056        }
057        public void setResponse(HttpServletResponse value) {
058                response = value;
059        }
060        /**
061         * Implicit Object.
062         * 
063         * <p>This managed property was also specified in
064         *    a managed-property tag in
065         *    WEB-INF/faces-config.xml
066         */
067        @ManagedProperty("#{param}")
068        protected Map<String,String> param;
069        public Map<String,String> getParam() {
070                return param;
071        }
072        /**
073         * Setter for {@link #param} managed bean.
074         * @param value 
075         */
076        public void setParam(Map<String,String> value) {
077                param=value;
078        }
079        /**
080         * Reference to implicit object.
081         * 
082         * <p>This property is set by a managed-property
083         *    statement in WEB-INF/faces-config.xml.</p>
084         */
085        protected Map<String,String> paramXml;
086        public Map<String,String> getParamXml() {
087                return paramXml;
088        }
089        public void setParamXml(Map<String,String> value) {
090                paramXml = value;
091        }
092        @ManagedProperty("#{param}")
093        protected Map<String,String> paramAnn;
094        public Map<String,String> getParamAnn() {
095                return paramAnn;
096        }
097        public void setParamAnn(Map<String,String> value) {
098                paramAnn = value;
099        }
100        /**
101         * Implicit object.
102         */
103        // ManagedProperty("#{cookie}")
104        protected Map<String,String> cookie;
105        public Map<String,String> getCookie() {
106                return cookie;
107        }
108        public void setCookie(Map<String,String> value) {
109                cookie = value;
110        }
111        /**
112         * Implicit object.
113         */
114        @ManagedProperty("#{session}")
115        protected HttpSession session;
116        public HttpSession getSession() {
117                return session;
118        }
119        public void setSession(HttpSession value) {
120                session = value;
121        }
122        /**
123         * Implicit object.
124         */
125        // ManagedProperty("#{facesContext}")
126        protected FacesContext facesContext;
127        public FacesContext getFacesContext() {
128                return facesContext;
129        }
130        public void setFacesContext(FacesContext value) {
131                facesContext = value;
132        }
133        /**
134         * Managed bean property for the name parameter in the
135         * HTTP call.
136         * <p>Perhaps I can use implicit objects with properties
137         * in the ManageProperty annotation, but not
138         * reference the implicit object directly.</p>
139         */
140        @ManagedProperty(value="#{param.name}")
141        protected String test1;
142        public String getTest1() {
143                return test1;
144        }
145        public void setTest1(String value) { 
146                test1 = value; }
147
148}