View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.orchestra.lib.jsf;
20  
21  import javax.faces.context.ExternalContext;
22  import javax.faces.context.ExternalContextWrapper;
23  
24  import org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterProviderManager;
25  
26  /**
27   * Class used by _PortletFacesContextWrapper to allow orchestra work in portlets
28   * 
29   * This class wraps encodeActionURL and encodeResourceURL to include
30   * conversationContext param like RequestParameterResponseWrapper does. In portlets
31   * we can't do the same than is servlets, because the params added here must be
32   * encoded by the portlet container and in portlets we don't have servlet redirect
33   * cases.
34   * 
35   * @author Leonardo Uribe(latest modification by $Author: lu4242 $)
36   * @version $Revision: 798382 $ $Date: 2009-07-27 22:23:02 -0500 (lun, 27 jul 2009) $
37   */
38  public class PortletExternalContextWrapper extends ExternalContextWrapper
39  {
40      private ExternalContext _delegate;
41  
42      public PortletExternalContextWrapper(ExternalContext context)
43      {
44          super();
45          this._delegate = context;
46      }
47      
48      @Override
49      public ExternalContext getWrapped()
50      {
51          return _delegate;
52      }
53  
54      public String encodeActionURL(String url)
55      {
56          if (url != null)
57          {
58              url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
59          }
60          return getWrapped().encodeActionURL(url);
61      }
62  
63      public String encodeResourceURL(String url)
64      {
65          if (url != null)
66          {
67              url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
68          }
69          return getWrapped().encodeResourceURL(url);
70      }
71  }