el.cache[] null or not an object - extjs

hi i have a treePanel on node dblClick listener i am opening a tab panel...it works for the most part but on some occasion i am getting this error el.cache[] null or not an object...does any one have any idea on how to solve this problem..please help

Sounds like an event isn't being cleaned up. Make sure that if you are listening to an event for a node in the tree, that the event will be cleaned up (that is, "unlistened") properly if the tree gets reloaded.
Are you ever reloading nodes in the tree? If so, I'd check any events tied directly to nodes.
If not, try and let us know if you are doing anything else funny with the tree, and see if you can post some code.

Related

Cypress, retrying against element thats no longer attached to the DOM

I'm currently using cypress to test that a 'pill' element is added on the frontend when the data gets to a particular state.
I identify the row being targeted using cy.contains()
I then chain it with parents('tr').contains('<string>') to identify that the pill I want is being added
The only problem is because the cleanup logic that happens prior to the test triggers a third party webhook that my app responds to, sometimes the row I'm targeting gets removed (after its been found using the first cy.contains() command) and then re-added to the DOM before it reaches its final state.
I believe this is then what causes the second part to fail - cypress appears not to have realised its been detached from the DOM and times out expecting to find my <string> on the detached node.
The full chain looks something like this
cy.get('table')
.find('tr') // Get all the rows
.contains('stringToIdentifyMyTableRow') // Get the text in the specific row I care about
.parents('tr') // broaden scope to whole row
.contains('pillString') // Find text I'm looking for
It seems like its found everything after the .parents('tr') command so its not bothering to retry, even when they are actually detached from the DOM - rather its continuing to look for the pillString in the detached node. What I'd like it to happen is for cypress to continually retry the whole chain until the application reaches its intended state.
Try updating to the latest version 12. It has a new feature that retries when elements are detached from the DOM docs.cypress.io/guides/references/changelog#12-0-0
Maybe try eliminating the .parents('tr') step
cy.get('table')
.contains('tr', 'stringToIdentifyMyTableRow')
.contains('pillString') // should be pill cell
It's easy to get detached errors with React because of the frequent re-render of components.
Your test has no action to cause a re-render, if the webhook is doing it then you need a way to start the test after the webhook has run.

What is the proper way to delete a tree node

import com.codename1.ui.tree.Tree;
import com.codename1.ui.tree.TreeModel;
Upon detecting a delete action from my tree ActionListener,
I delete the path on disk.
FileSystemStorage.getInstance().delete(node.getPath());
Then attempt to refresh the tree where there is one less element in the curr node.
tree.expandPath(true,(Object[]) (node.getNodeParent().getNodesOnPath()));
Can you please provide a working example of delete a single leaf (file) and then refresh the Node Parent
My approach does not work.
If I manually tap on the Node Parent twice, I see the file id no longer displayed as expected.
Thanks in advance.
Once it's shown the tree won't refresh unless you refresh the whole thing. Only hidden nodes take events into account so if you fold and reopen it will update. In the case of deletion you can just use something specific to the file and remove the specific node components from their parents directly which is a bit of a hack.
Alternatively you can refresh the entire tree which is what we do for the GUI builder by setting a new instance of the model. In the GUI builder that's practical because the tree is always expanded. It might be a bit painful for your implementation.

Memory Management in AngularJS

I am new to angular, so maybe I'm going about this completely wrong. I am attempting to make a treeView with angularJS directives. The code that I have so far accomplishes this, except that there appears to be a memory leak as each time the tree view reloads it slows down, and eventually crashes the browser.
I have created the following two directives to accomplish my task jscTreeView and jscTreeNode
This fiddler has my source, it builds you a random tree, and gives you the ability to choose the amount of nodes in the tree. If you bump that number up to a higher number, and reload several times you will notice that it progressively slows down to each time.
Any ideas on how to clean up after myself would be greatly appreciated, thanks.
Edit:
This fiddler is a second attempt with this one I went in a completely different direction. It is much more efficient, and the code is more clean in my opinion. However, this one has an issue too. periodically, and seemingly randomly on refresh of the tree this one throws an infinite digest exception.
Note: not all of the functionality that was in the former tree is in the current tree yet. That is just because I have not programmed it yet.
As the discussion in the comments indicates, I was creating, but never properly releasing, scopes in my tree view. While the solution was not very easy to figure out it is actually quite an easy solution, and clarified things a lot for me.
What I needed to do was make a clone of the root scope of my tree var newScope = scope.$new();, I then built all of the rest of the subtrees as well as their associated nodes and compiled with the cloned scope newScope. After the compile it stores the cloned scope into a variable private to the directive lastScope = newScope;. When the watch property is updated, and calls back to my directive the last cloned scope is destroyed lastScope.$destroy();. Destroying that cloned scope automatically destroys any child scope created beneath it (the nodes, as well as the subtrees). A new clone of the scope is created, and the process is repeated, thanks to #Jorg's tool to count scopes, I can see that everything is being cleaned up nicely on each iteration. Here is a fiddle to the solution.

Re-attaching Marionette.View and events handling

Lets say, that I’ve got simple app, which is created with Backbone.Marionette.
For sake of simplicity, assume that I’ve got „Show” view for some model (it doesn’t matter here what it is), where I can click „Add new”, which shows me „new” view in „modal” window.
I’m displaying there simple form, which (after validation) is sent to my API. During that, I’m displaying other view (which displays sth. like „Saving, please wait…”).
In case of success, I’m closing this modal window, and everything is OK.
However (that is the tricky part): I would like to handle situations, when from some reason model was not saved (API temporary downtime, connection issue, race condition etc.), and display same view another time (I thought that it should be easy) – however, when I’m doing this, events aren’t handled anymore (ie: submitForm action is not executed second time :( )
Here is my my proof of concept for this:
class MyApp.SampleView extends Marionette.View
events:
"submit form": "submitForm"
submitForm: (event) ->
event.preventDefault()
data = $(event.currentTarget).serializeObject()
model = SampleModel.new(data)
if model.isValid()
MyApp.popupRegion.show(SavingPopup)
savePromise = model.save()
savePromise.success =>
#close()
#displayNotification("Model has been added")
savePromise.error =>
#displayNotification("Something went wrong, please try again")
MyApp.popupRegion.show(this) # displays correct view
# but does not handle events :(
TL;DR version:
How to re–append view to region in such way that my events still will be handled?
Before a region show()'s a view it calls close() on the currently displayed view. close() acts as the view's destructor, unbinding all events, rendering it useless and allowing the garbage collector to dispose of it.
When you execute MyApp.popupRegion.show(SavingPopup), this is close()'d. You will need to create a new instance of the view in savePromise.error, or find some other way to signal your application that the view needs to be recreated.
Something like this should work:
savePromise.error =>
#displayNotification("Something went wrong, please try again")
MyApp.popupRegion.show(new MyApp.SampleView)

Reload a whole tree or a single node

How can I either reload a whole tree and/or a single node allong with all childs of these node from the scope of the node.
The Single-Node currently this is done by expanding but now there is the need for a reload button for the whole grid and for the selected node. I looked at the nodeinterface there is is nothing useful like a reload. The node are using a automodel at the moment, meaning no explicit model is created.
revished edit
I also tried to call removeAll() on a treestore and also removeAll() on the tree. The first calls the reader method for each removed node with the node itself as param which then result in a error cause there server answer all the invalid request with a empty result. The second removes all but also with errors.
Any help is appreciated!
For your second question:
You might try call the removeAll() of the tree instead of the store.

Resources