This section is made up :
JSPTabControl use following therminology :
tab control header and tab control body are included into a global div HTML element.
Go to section HTML generated, for more information.
With JSPTabControl, you can assign a state (READ-ONLY, FORBIDDEN, ...) for each tabPage. In this top example Tab page 3 is assigned with FORBIDDEN state. A state define :
To use JSPTabControl, you must :
<script type="text/javascript" src="js/jsptabcontrol.js" ></script>
<link href="/css/my-jsptabcontrol.css" rel="stylesheet" type="text/css"/>
<jsptabcontrol:tabControl name="MY_TABCONTROL" width="500px" height="50px" tabHeaderClass="tabHeader2" tabBodyClass="tabBody2" > <jsptabcontrol:tabPage name="MY_TABPAGE1" title="Tab page 1" width="150px" > Tab Page 1 content </jsptabcontrol:tabPage> .... </jsptabcontrol:tabControl>
See section JSPTabControl Taglib for more information.
You can use JSPTabControl with :
Attribute Name | Description | Required ? | EL ? |
name | Name of Tab control. This Name for tab control must be unique in your JSP. It is used to identify tab control (used for example to select a tab page with Action Struts). | True | True |
width | Width of Tab control. | False | True |
height | Height of Tab control. | False | True |
tabControlHeaderClass | Style Class of tab control header. | False | True |
tabControlBodyClass | Style Class of tab control body. | False | True |
bundleKey | Resource bundle key (eg : net.sourceforge.jsptabcontrol.usecase.MyResourceBundle). | False | True |
localeKey | Locale key ("fr","en", ...) or key of Locale object, stored into request. | False | True |
Attribute Name | Description | Required ? | EL ? |
name | Name of Tab page. This Name for tab page must be unique for tab control. It is used to identify tab page (used for example to select a tab page with Action Struts). | True | True |
width | Width of Tab page. | False | True |
title | Title of Tab page. | False | True |
titlekey | Key of title which is used to get label of title into Resources file (ApplicationResources or Resource Bundle). | False | True |
href | You can use href, to manage tab page with runat server. | False | True |
tabPageHeaderClass | Style Class of tab page header. | False | True |
tabPageBodyClass | Style Class of tab page body. | False | True |
Before configurate JSPTabControl with CSS, you must know HTML generated by taglib. see section HTML generated.
By default, JSPTabControl use ApplicationResources of Struts like messages resources. If you use JSPTabControl with Struts, there is nothing to do.
If you want use your own file, it's possible to parameter the resource bundle to use like this :
<jsptabcontrol:tabControl name="PERSONNE_TABCONTROL" bundleKey="net.sourceforge.jsptabcontrol.usecase.MyResourceBundle" localeKey="en" > .... </jsptabcontrol:tabControl>
In this case, file MyResourceBundle_en.properties, stored into package net.sourceforge.jsptabcontrol.usecase will be use like messages resources.
JSPTabControlUtil is util class for manage tab pages of tab control.
To select tab page MY_TABPAGE2 of tab control MY_TABCONTROL, you can call method setSelectedTabPageName in your Action Struts (or in your JSP) :
JSPTabControlUtil.setSelectedTabPageName(request, "MY_TABCONTROL", "MY_TABPAGE2");
States definition are configurated into configuration XML jstabcontrol-config.xml file which must check the jsptabcontrol-config-1.0.dtd DTD.
Each state define :
<insert-styleclass where="tabPageHeader" > <![CDATA[tabPageHeaderReadOnly]]> </insert-styleclass>
<insert-styleclass where="tabPageBody" > <![CDATA[tabPageBodyReadOnly]]> </insert-styleclass>
<insert-javascript event="onclick" where="before" > <![CDATA[alert('You are not authorized to select this tab page!');return false;]]> </insert-javascript>
Onclick event is particulary, because by default javascript (TabToggle function) is generated to select tab page selected. If you want insert javascript before javascript TabToggle function, set where="before" into insert-javascript element.
Here an example of jstabcontrol-config :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jsptabcontrol-config PUBLIC "-//JSPTabControl/JSPTabControl JSPTabControlConfig DTD 1.0//EN" "http://jsptabcontrol.sourceforge.net/dtd/jsptabcontrol-config-1.0.dtd"> <jsptabcontrol-config> <tabpage-states> <!-- Render of Tab page with DISABLE state --> <tabpage-state name="READ-ONLY"> <insert-styleclass where="tabPageHeader" > <![CDATA[tabPageHeaderReadOnly]]> </insert-styleclass> <insert-styleclass where="tabPageBody" > <![CDATA[tabPageBodyReadOnly]]> </insert-styleclass> </tabpage-state> <!-- Render of Tab page with FORBIDDEN state --> <tabpage-state name="FORBIDDEN"> <insert-styleclass where="tabPageHeader" > <![CDATA[tabPageHeaderForbidden]]> </insert-styleclass> <insert-javascript event="onclick" where="before" > <![CDATA[alert('You are not authorized to select this tab page!');return false;]]> </insert-javascript> </tabpage-state> <!-- Render of Tab page with INVISIBLE state --> <tabpage-state name="INVISIBLE" visible="false" > </tabpage-state> </tabpage-states> </jsptabcontrol-config>
You can save /WEB-INF/jstabcontrol-config.xml configuration with Plugin Struts, like this :
<!-- JSPTabControl Plugin --> <plug-in className="net.sourceforge.jsptabcontrol.struts.plugin.JSPTabControlPlugin"> <set-property property="jspTabControlConfig" value="/WEB-INF/jstabcontrol-config.xml"/> </plug-in>
If you don't want use Struts, you can use JSPTabControlServlet, like this :
<!-- Servlet JSPTabControlServlet which load config of JSPTabControl --> <servlet> <servlet-name>jspTabControl</servlet-name> <servlet-class>net.sourceforge.jsptabcontrol.servlet.JSPTabControlServlet</servlet-class> <!-- JSPTabControl Config files (Required) --> <init-param> <param-name>jspTabControlConfig</param-name> <param-value>/WEB-INF/jsptabcontrol-config.xml</param-value> </init-param> </servlet>
To set READ-ONLY state for tab page MY_TABPAGE2 of tab control MY_TABCONTROL, you can call method setTabPageState in your Action Struts (or in your JSP) :
JSPTabControlUtil.setTabPageState(servletContext, request, "MY_TABCONTROL", "MY_TABPAGE2", "READ-ONLY");
If you want manage selection of tab page with Javascript, you can call javascript function setSelectedTabPageName of javascript file jsptabcontrol.js. You could use this function to display a next tab button to select the next tab selected.
For instance to select tab page MY_TABPAGE2 of tab control MY_TABCONTROL, you use this function like this :
setSelectedTabPageName("MY_TABCONTROL", "MY_TABPAGE2"); ...
If force is true, the tab is selected, otherwise this function call onclick event of tab. For instance if your tab is FORBIDDEN, you can manage if you execute your permission (display an alert) or not.
Once you have configure states (see section How manage tab page state?), you can set a state for a tab page, whith client side. For this, you must include javascript file jsptabcontrol-states.js
<script type="text/javascript" src="js/jsptabcontrol-states.js" ></script>
and call taglib jsptabcontrol:javascriptStateConfig, which get your config, and generate list of state into object javascript.
<jsptabcontrol:javascriptStateConfig />
To set a state por a particulary tab, you can use setTabPageState function. For instance to set state FORBIDDEN to tab page MY_TABPAGE2 of tab control MY_TABCONTROL, you use this function like this :
setTabPageState("MY_TABCONTROL", "MY_TABPAGE2", "FORBIDDEN");
By default tab page selection is client side, managed by javascript function (TabToggle function). But you can manage your tab page with runat server, by using href attribute of taglib tabPage. To select the tab page after calling url of href, you must understand, how JSPTabControl manage the last tab page selected.
For keep tab page selected after posting form, JSPTabControl generate an input hidden by using name of tabControl. For tabControl with name MY_CONTROL, input hidden generated is like this :
<input type="hidden" id="tabPageInputHiddenName_MY_TABCONTROL" name="tabPageInputHiddenName_MY_TABCONTROL" value="" />
Value of this input hidden element contains the last name of tab page selected. So your url into your href must be like this :
<jsptabcontrol:tabPage name="ADRESS_TABPAGE" title="Adress Tab" href="/myAction.do?tabPageInputHiddenName_MY_TABCONTROL=ADRESS_TABPAGE"> .... </jsptabcontrol:tabPage>