KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > portlet > PortletLinkFactoryImpl


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

15 package org.apache.tapestry.portlet;
16
17 import java.util.Map JavaDoc;
18
19 import javax.portlet.PortletURL;
20 import javax.portlet.RenderResponse;
21
22 import org.apache.hivemind.util.Defense;
23 import org.apache.tapestry.IRequestCycle;
24 import org.apache.tapestry.engine.ILink;
25 import org.apache.tapestry.services.impl.LinkFactoryImpl;
26 import org.apache.tapestry.util.QueryParameterMap;
27
28 /**
29  * Extended version of {@link org.apache.tapestry.services.impl.LinkFactoryImpl} that can
30  * create generate Portlet URLs.
31  *
32  * @author Howard M. Lewis Ship
33  * @since 4.0
34  */

35 public class PortletLinkFactoryImpl extends LinkFactoryImpl
36 {
37     private RenderResponse _renderResponse;
38
39     public void setRenderResponse(RenderResponse renderResponse)
40     {
41         _renderResponse = renderResponse;
42     }
43
44     public ILink constructLink(IRequestCycle cycle, Map JavaDoc parameters, boolean stateful)
45     {
46         Defense.notNull(cycle, "cycle");
47         Defense.notNull(parameters, "parameters");
48
49         squeezeServiceParameters(parameters);
50
51         PortletURL url = _renderResponse.createActionURL();
52
53         return new PortletLink(cycle, url, new QueryParameterMap(parameters), stateful);
54     }
55 }
Popular Tags