4

I need to relaod a sj:tab in struts2-jquery 3.3.3, so far i tried:

  • Add a listenTopic to sj:tab, didn't work as i read it wasn't yet implemented in that version
  • Upon any event, reload the tab like:

$('#myPanel').tabs("load", "#myTab");

It works and reloads, but some more event handlers bind and when i submit via sj:submit, it submits twice, i've tried to remove all event handlers with jquery before reload, but i doesn't make any difference. So the event handlers grow exponetially:

> $('#myPanel').tabs("load", "#myTab");  
1 event handler per button 
> $('#myPanel').tabs("load", "#myTab");
2 
> $('#myPanel').tabs("load", "#myTab"); 
4 .. 16 .. 32

How do i kill all those event handlers in sj:submit?

user311174
  • 1,738
  • 1
  • 18
  • 17

1 Answers1

0

This was probably a bad smell from me as i needed to change a tab upon a new 'state' in the app, so i thought this would be a good idea:

( ajax call fired by a sj:submit --> POST )
# in the server check if the state changed, if so returns success and the client asks to reload.

$.subscribe("change_state"){
  ...
  $('#myPanel').tabs("load", "#myTab");
  # (http GET new tab)
};

The tab loads smoothly, but to prevent the old events to fire i had to setup variables for each button

$.subscribe("change_state", function(event){
  if (!reloaded){
     $('#myPanel').tabs("load", "#myTab");
     reloaded = 1;
  }
)};
$.document.ready(function(){
    reloaded = null;
});

If someone have the right design for this version of struts i'd gladly offer the 100 bounty

user311174
  • 1,738
  • 1
  • 18
  • 17