struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <>
Subject Re: Tabbed Panel and useSelectedTabCookie
Date Wed, 12 Dec 2007 07:52:56 GMT
quinquin2209 wrote:
> I have tried to store the last selected tab by setting
> useSelectedTabCookie=true. It works fine as long as the tab remains.
> However, problem occurs when the last selected is removed as follow:
> 1. User select tab "B"
> 2. In the jsp, remove the tab with id "B"
> 3. Refresh the browser
> Javascript error throw when the above steps are performed. 
> Is there any way to solve it??

I didn't know this feature existed but it seems you've found a bug.

I've always saved the selection in a cookie manually:
  1. when a tab is selected, save the current tab's id in a cookie
  2 when the page is loaded, read the cookie and set the selected tab 
(if it exists!)

Code extract:
Note i) createCookie and readCookie are your own functions
        ii)  init* methods need to be called on the page load event 

Step 1:  a setup listeners for a tab selection and write a cookie

  function onTab1Selected(evt) {
    createCookie("selectedTab", "tab1", 60);

  function initListeners() {
     var tab1Widget = dojo.widget.byId("tab1");
     dojo.event.connect("before", tab1Widget, "show", onTab1Selected);

Step 2: on page load, read the cookie and set the selected tab

function init() {
   var selectedTabId = readCookie(selectedTab);
   if (selectedTabId) {
     var selectedTabWidget = dojo.widget.byId("selectedTabId");
     if (selectedTabWidget ) {
         var tabbedContainerWidget = dojo.widget.byId("tabContainerId");

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message