Removing a window and reopen

Hi Guys!

I have a windowarea, which is filled with windows from a java servlet. It' is working fine. I using this script to remove the window:

<e:call with="id('waMain')" method="removeChild" node="id($cWinId)"/>

It means, that I'd like to reduce a size of the dom tree, and this is different from the Bacbase philosophy which is hides the closed windows,and not removes it from the windowarea.

It is working fine too, and the window looks "removed" when I'm using this scipt. But my problem is the next: When I reopen the mentioned window, the BB says: "Build: Multiple ID occurrence.."

My question is: how can I remove totally a window from the page, and how can I solve the error and warningless reopening.

Thx
Tom.

Removing a window and reopen

Hi Tom,

If you use removeChild method, it is only remove the element from the DOM but not automatically destroy the element from the memory.To ensure that all object used by the controller are removed from memory, then you should use a destructor method such as bb.command.destroy(this) or bb.destruct(oMyElement). Hope this help :)

working with some problems

Thank you very much the answer Yudi. It's ok now from the viewpoint of windowArea. But my structure looks like this:

...
<b:panel id="pnSubWPB">
     <b:windowArea  id="waMain"  display="true"/>            
</b:panel>
<b:panel id="pnSubWPC">                    
     <b:taskBar orientation="bottom" windowArea="id('waMain')" />                                          
</b:panel>
....

In this situation, the taskbar logging errors after a total removing of a window. Do you have any method or solution to handle this situation in the taskbar?

Destruct all windows inside the windowArea

hi tamas.kovacs,

May be you have removed windowArea (id="waMain") and that's why the taskbar shows error because it can not find the windowArea. This is example how to destruct only the child's element (the window) of the windowArea.Perhaps this solves your problem :)

var childNodes = bb.document.getElementById('waMain').getProperty('childNodes');
if (childNodes){
for(var i=0;i<childNodes.length;i++){
        bb.destruct(childNodes[i]);
}

'Kill' definitely a window widget

I have same problem and has tried various codes, someone has a working example of how to kill definitely a window widget? There is a possibility that WindowArea widget simply kill the window object when it is closed?

'Kill' definitely a window widget

Hi rribeiro,

I don't have a working example to kill definitely a window widget but there are various examples ( using XEL and javascript)how to use destroy method from the reference. It should work the same way for the window widget.

<div id="tobedestroyed">
We will destroy this widget and remove it from memory.
</div>
<div>
Click to destroy widget.
<e:handler event="click">
<c:destroy with="id('tobedestroyed')" />
</e:handler>
</div>
<div id="destroyMe">My sole purpose is to get destroyed</div>
<div>
Click to destroy everything
<e:handler event="click" type="text/javascript">
bb.command.destroy(bb.getProperty(this,'parentNode'));
</e:handler>
</div>

it is possible to make window destroys itself when it is closed but then you have to make your own window widget extended from b:window and overwrite the window's "close" method by adding code to destroy the window.
bb.callSuper("close");
bb.command.destroy(this);

'Kill' definitely a window widget

Ok. I will create and run this code, and return with the result.

Grateful

don´t run

I try all possible code that i know and the code posted on forum, but don´t run, always the debugger advice about error when i try to recreate the object. I can work hiding the windows and then presents them, but destroying and creating not working. The debugger says that the 'name' is already in use.

custom window that destroy itself when it is closed

Hi rribeiro,

Actually previous code works but may be the example not enough.I created another example for the custom window that destroy itself when it is closed.

//index.html
<div id="myElm" style="border: 1px solid black; width: 300px;">
Created elements will be the last children of this widget.
</div>
<div>
Click to create new elements
<e:handler event="click">
<c:create destination="id('myElm')" mode="appendChild">
<m:customWindow id="1" label="Test"/>
</c:create>
</e:handler>
</div>

//write this in your tdl for making custom widget
<d:element name="customWindow" extends="b:window">
<d:method name="close">                
<d:body type="text/javascript">
bb.callSuper("close");
bb.command.destroy(this);                                      
</d:body>
</d:method>
</d:element>           

So in above example, it shows how to create custom window extended from b:window and add destroy command on its "close" method.

Kill windows

hi yudi,

I will try it and return, i have developed another code too, soon I will post it on the forum.

thanks

Kill window

too late .... It's work fine, but i want kill a specific window in windowArea/taskBar widget, do you know how i can do this ??