Window link taglib ver. 1.2

    Custom JSP taglib. Mimics HTML hyperlinks (<a> tag) with the specified URL but opens the target location in the separate popup window. In other words you can keep users (visitors) on the main page while opening a new location. There are two options for filling that popup: iframe or Ajax call. For example, the following code will open your link in the iframe:

For example:
 


<script language="JavaScript" src="cjajax.js"></script>
<%@ taglib uri="taglib.tld" prefix="wl" %>
<html>
...
<wl:winlink iframe="true" title="Google about Coldbeans" href="http://www.google.com/search?q=Coldbeans">Google about Coldbeans</wl:winlink>
...
</html>

And you will get some like this:

Google about Coldbeans

Otherwise (without the attribute iframe) the target site will be requested via Ajax and returned HTML displayed in the popup window. E.g. in this case:
 


<script language="JavaScript" src="cjajax.js"></script>
<%@ taglib uri="taglib.tld" prefix="wl" %>
...
<wl:winlink href="/servlet/Next">Next Step</wl:winlink>
...

tag will request /servlet/Next and displays the response in in the popup window.

Tag supports sessions, so URL rewriting will be added automatically. Also tag lets you add a random unique parameter to the generated link (a standard trick for non-cached requests). In order to use this tag with Ajax you have to describe an external JavaScript file cjajax.js on your page.

You can set a text for your hyperlink as a tag's body or through the special tag setText. Tag setParameter lets you define a GET parameter for the link (value will be encoded automatically):
 


<%@ taglib uri="taglib.tld" prefix="wl" %>
<html>
...
<wl:winlink href="http://www.server.com/nextpage.htm">
 <wl:setText>Next page</wl:setText>
 <wl:setParameter name="A">value for A</wl:setParameter>
 <wl:setParameter name="B">value for B</wl:setParameter>
</wl:winlink>
...
</html>

Tags are:

winlink

Body tag renders HTML hyperlink that will be opened in the window. Parameters are:

1) href Optional parameter. Describes an URL. By default tag will use the current URL (request URI).
2) title Optional parameter. Describes a title (tooltip).
3) className Optional parameter. Describes a CSS class for your link.
4) style Optional parameter. Describes a CSS style for your link. Default value is cursor:pointer;color:blue;text-decoration:underline;
5) unique Optional parameter. Possible values are true or false. If this value is true tag adds an unique parameter to the link that makes it non-cached. Default value is false (do not add).
6) windowClass Optional parameter. Describes a CSS class for your window. By default tag will use the following settings: BORDER-RIGHT: #000 2px solid; PADDING-RIGHT: 10px; BORDER-TOP: #000 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: #000 1px solid; WIDTH: 100%; PADDING-TOP: 10px; BORDER-BOTTOM: #000 1px solid; BACKGROUND-COLOR: white
7) titleClass Optional parameter. Describes a CSS class for the title in your window.
8) titleStyle Optional parameter. Describes a CSS style for the title in your window. Default value is cursor:pointer;background:blue;color:white;text-decoration:none
9) width Optional parameter. Describes a width for your window. Default value is 500px.
10) height Optional parameter. Describes a height for your window. Default value is 400px.
11) top Optional parameter. Describes a top position for your window.
12) left Optional parameter. Describes a left position for your window.
13) iframe Optional parameter. Possible values are true or false. If this value is true tag will use iframe for the provided url. Default value is false.
14) close Optional parameter. Possible values are true or false. If this value is true tag allows closing for the opened popups. Default value is true.
15) drag Optional parameter. Possible values are true or false. If this value is true tag allows drag-and-drop for the opened windows. Default value is true.
16) rel Optional parameter. Describes a rel attribute.

setText

Body tag defines a text for your hyperlink. Parameters are: none

setParameter

Body tag defines a parameter for your hyperlink. Parameters are:

1) name Describes a name for your parameter

for downloading:

Library: winlinktag.jar    Description: taglib.tld  JavaScript library: cjajax.js

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: