This project has retired. For details please refer to its Attic page.
StateAwareRequestDelegate xref
View Javadoc

1   /*
2    * $Id: StateAwareRequestDelegate.java 1066849 2011-02-03 16:12:39Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.tiles.request.portlet.delegate;
22  
23  import java.util.Map;
24  
25  import javax.portlet.PortletRequest;
26  import javax.portlet.StateAwareResponse;
27  
28  import org.apache.tiles.request.collection.AddableParameterMap;
29  import org.apache.tiles.request.portlet.extractor.StateAwareParameterExtractor;
30  
31  /**
32   * Exposes parameters getting them from a portlet reques and allowing to be put
33   * into a {@link StateAwareResponse}.
34   *
35   * @version $Rev: 1066849 $ $Date: 2011-02-04 03:12:39 +1100 (Fri, 04 Feb 2011) $
36   */
37  public class StateAwareRequestDelegate implements RequestDelegate {
38  
39      /**
40       * The request.
41       */
42      private PortletRequest request;
43  
44      /**
45       * The response.
46       */
47      private StateAwareResponse response;
48  
49      /**
50       * Constructor.
51       *
52       * @param request The request.
53       * @param response The response.
54       */
55      public StateAwareRequestDelegate(PortletRequest request,
56              StateAwareResponse response) {
57          this.request = request;
58          this.response = response;
59      }
60  
61      /**
62       * <p>The lazily instantiated <code>Map</code> of request
63       * parameter name-value.</p>
64       */
65      private Map<String, String> param = null;
66  
67      /**
68       * <p>The lazily instantiated <code>Map</code> of request
69       * parameter name-values.</p>
70       */
71      private Map<String, String[]> paramValues = null;
72  
73      /** {@inheritDoc} */
74      public Map<String, String> getParam() {
75          if ((param == null) && (request != null)) {
76              param = new AddableParameterMap(new StateAwareParameterExtractor(
77                      request, response));
78          }
79          return (param);
80      }
81  
82      /** {@inheritDoc} */
83      public Map<String, String[]> getParamValues() {
84          if ((paramValues == null) && (request != null)) {
85              paramValues = new StateAwareParameterMap(request.getParameterMap(),
86                      response.getRenderParameterMap());
87          }
88          return (paramValues);
89      }
90  }