|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
PopupLinkRenderer.java | 0% | 0% | 0% | 0% |
|
1 |
// Copyright 2004, 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.contrib.link;
|
|
16 |
|
|
17 |
import org.apache.tapestry.IRequestCycle;
|
|
18 |
import org.apache.tapestry.engine.ILink;
|
|
19 |
import org.apache.tapestry.link.DefaultLinkRenderer;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* This renderer emits javascript to launch the link in a window.
|
|
23 |
*
|
|
24 |
* @author David Solis
|
|
25 |
* @since 3.0.1
|
|
26 |
**/
|
|
27 |
public class PopupLinkRenderer extends DefaultLinkRenderer |
|
28 |
{ |
|
29 |
|
|
30 |
private String _windowName;
|
|
31 |
|
|
32 |
private String _features;
|
|
33 |
|
|
34 | 0 |
public PopupLinkRenderer()
|
35 |
{ |
|
36 |
} |
|
37 |
|
|
38 |
/**
|
|
39 |
* Initializes the name and features for javascript window.open function.
|
|
40 |
*
|
|
41 |
* @param windowName the window name
|
|
42 |
* @param features the window features
|
|
43 |
*/
|
|
44 | 0 |
public PopupLinkRenderer(String windowName, String features)
|
45 |
{ |
|
46 | 0 |
_windowName = windowName; |
47 | 0 |
_features = features; |
48 |
} |
|
49 |
|
|
50 |
/**
|
|
51 |
* @see DefaultLinkRenderer#constructURL(org.apache.tapestry.engine.ILink, String, org.apache.tapestry.IRequestCycle)
|
|
52 |
*/
|
|
53 | 0 |
protected String constructURL(ILink link, String anchor, IRequestCycle cycle)
|
54 |
{ |
|
55 | 0 |
String url = link.getURL(anchor, true);
|
56 | 0 |
return "javascript: w = window.open(" + normalizeString(url) + ", " + normalizeString(getWindowName()) + ", " + normalizeString(getFeatures()) + "); w.focus();"; |
57 |
} |
|
58 |
|
|
59 | 0 |
private String normalizeString(String str)
|
60 |
{ |
|
61 | 0 |
return str == null ? "''" : "'" + str + "'"; |
62 |
} |
|
63 |
|
|
64 | 0 |
public String getWindowName()
|
65 |
{ |
|
66 | 0 |
return _windowName;
|
67 |
} |
|
68 |
|
|
69 | 0 |
public void setWindowName(String windowName) |
70 |
{ |
|
71 | 0 |
_windowName = windowName; |
72 |
} |
|
73 |
|
|
74 | 0 |
public String getFeatures()
|
75 |
{ |
|
76 | 0 |
return _features;
|
77 |
} |
|
78 |
|
|
79 | 0 |
public void setFeatures(String features) |
80 |
{ |
|
81 | 0 |
_features = features; |
82 |
} |
|
83 |
} |
|
84 |
|
|