KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > util > TabsUtil


1 /*
2  * Created on 5 oct. 2004
3  *
4  * Copyright Improve SA
5  * All right reserved
6  */

7 package fr.improve.struts.taglib.layout.util;
8
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import javax.servlet.http.HttpServletResponse JavaDoc;
11
12 import org.apache.commons.logging.Log;
13 import org.apache.commons.logging.LogFactory;
14
15 import fr.improve.struts.taglib.layout.tab.TabTag;
16
17 /**
18  * Simple utilities for the tabs
19  *
20  * @author JN Ribette
21  */

22 public class TabsUtil {
23     private static final Log LOG = LogFactory.getLog(TabsUtil.class);
24     
25     /**
26      * Set the current tab in a tag group.
27      * @param in_tabsGroup the value specified in the jsp under the selectedTabKeyName attribute of the tabs tag
28      * @param in_selectedTabKey the selected tab key
29      * @param in_request the http request.
30      */

31     public static void setCurrentTab(String JavaDoc in_tabsGroup, String JavaDoc in_selectedTabKey, HttpServletRequest JavaDoc in_request, HttpServletResponse JavaDoc in_response) {
32         // Check parameters.
33
if (in_tabsGroup==null || in_tabsGroup.length()==0) {
34             throw new IllegalArgumentException JavaDoc("in_tabsGroups cannot be null or empty");
35         }
36         if (in_selectedTabKey==null || in_selectedTabKey.length()==0) {
37             throw new IllegalArgumentException JavaDoc("in_selectedtabKey cannot be null or empty");
38         }
39         if (in_request==null) {
40             throw new IllegalArgumentException JavaDoc("in_request cannot be null");
41         }
42         
43         if (LOG.isDebugEnabled()) {
44             LOG.debug("Selecting tab '" + in_selectedTabKey + "' for tabs '" + in_tabsGroup + "'");
45         }
46         
47         // Set request attribute.
48
in_request.setAttribute(in_tabsGroup, in_selectedTabKey);
49         
50         // Set cookie value.
51
TabTag.setSelectedTabNameFromCookie(in_request, in_response, in_tabsGroup, in_selectedTabKey);
52     }
53 }
54
Popular Tags