Using jstree v3 I have
this.elements.$tree.jstree({
core: {
data: function (node, successCallback) {
// Handle node expansion
thisTmp._expandNode(node, successCallback);
},
...
This works fine the first time I open a node and goes to my server and gets the child nodes. If I then close the node it is also called and I'd like to not bother the server at that point. Additionally if I then re-open the node this function is not called at all.
Investigating I noticed that the node passed always has a state of loading: true with all others set false.
Further investigation shows that this function is called before the before_open.jstree event, and after the after_close.jstree event. This probably explains the node state but doesn't help me.
I need it to call the webserver every time I open the node because the items represented by the child nodes may have changed since the last time you looked. That is there may be more/different/fewer nodes.
Spent all morning on this and can't see what I'm doing wrong (or should do differently). Any ideas?
Thanks
OK I've found a solution...
In the after_close event I set the node's loaded state to false. This causes jstree to trigger the loading again when I next open the node and I get any updated tree items.
Related
I have multiple process producing traces in separate files, so I want to sync them to display on a single timeline. Let's say I have 2 files.
agent_service_trace.json:
{"traceEvents":[
{"cat":"AgentService","pid":6876,"tid":6868,"ts":0,"ph":"X","name":"wWinMain","args":{},"dur":448701329},
{"cat":"","pid":6876,"tid":6868,"ts":3,"ph":"M","name":"process_name","args":{"name":"AgentService"}},
{"cat":"","pid":6876,"tid":6868,"ts":20,"ph":"M","name":"thread_name","args":{"name":"Main thread"}}
]}
agent_host_trace.json:
{"traceEvents":[
{"cat":"AgentHost","pid":6564,"tid":6440,"ts":0,"ph":"X","name":"wWinMain","args":{},"dur":448701329},
{"cat":"","pid":6564,"tid":6440,"ts":5,"ph":"M","name":"process_name","args":{"name":"AgentHost"}},
{"cat":"","pid":6564,"tid":6440,"ts":10,"ph":"M","name":"thread_name","args":{"name":"Main host"}}
]}
They are started with slight difference in time, from few seconds up to few minutes. When I'm combining them one by one, since ts arg is time from the beginning of process tracing, they looks like were started at the same point in time.
From the tracing documentation and clock sync addition especially, I'v found that Clock Sync event was created to handle multiple trace logs produced by different tracing agents and synchronize their clock domains. But as I know chrome://tracing doesn't support multiple files at time. The thing I'v tried so far, were adding clock_sync to events:
{"traceEvents":[
{"ts":0,"ph":"c","name":"clock_sync","args":{"sync_id":"guid0","sync_ts":0}},
{"cat":"AgentService","pid":6876,"tid":6868,"ts":0,"ph":"X","name":"wWinMain","args":{},"dur":448701329},
{"cat":"","pid":6876,"tid":6868,"ts":3,"ph":"M","name":"process_name","args":{"name":"AgentService"}},
{"cat":"","pid":6876,"tid":6868,"ts":20,"ph":"M","name":"thread_name","args":{"name":"Main thread"}},
{"ts":0,"ph":"c","name":"clock_sync","args":{"sync_id":"guid1","sync_ts":30000}},
{"cat":"AgentHost","pid":6564,"tid":6440,"ts":0,"ph":"X","name":"wWinMain","args":{},"dur":448701329},
{"cat":"","pid":6564,"tid":6440,"ts":5,"ph":"M","name":"process_name","args":{"name":"AgentHost"}},
{"cat":"","pid":6564,"tid":6440,"ts":10,"ph":"M","name":"thread_name","args":{"name":"Main host"}}
]}
I really don't know how this supposed to work, I'v tried to add sync_id as arg to events, also tried add pid as arg to clock_sync event. All of mine manipulations had no effect. I though there must be a link inbetween events and clock_sync's sync_id, but unable to find any info on this. I would appreciate any help.
How do you know when the Polymerfire firebase-document element is synced?
To be specific the firebase-document binds with an object via its data attribute. The value of this object goes from undefined --> { } --> {actual persisted data}.
How can you listen for firebase-document completing it's instal data fetch from the server. I am trying to check if there is data written at that location.
There is an issue open for this on GitHub. It is an unfortunate side effect caused by the solution to some other problem the author was trying to solve.
For now, all you can do is check that the object is empty (something like Object.keys(obj).length === 0) and do nothing if so.
You can't store an empty object in firebase, so if the data you are given is {}, you usually know it hasn't loaded yet.
I had a non-OSGi application. To convert it to OSGi, I first bundled it up and gave it a simple BundleActivator. The activator's start() started up a thread of what used to be the main() of my app (and is now a Runnable), and remembered that thread. The activator's stop() interrupted that thread, and waited for it to end (via join()), then returned. This all seemed to be working fine.
As a next step in the OSGiification process, I am now trying to use OSGi configuration management instead of the Properties-based configuration that the application used to use. So I am adding in a ManagedService in addition to the Activator.
But it's no longer clear to me how I am supposed to start and stop my application; examples that I've seen are only serving to confuse me. Specifically, here:
http://felix.apache.org/site/apache-felix-config-admin.html
They no longer seem to do any real starting of the application in BundleActivator.start(). Instead, they just register a ManagedService to receive configuration. So I'm guessing maybe I start up the app's main thread when I receive configuration, in the ManagedService? They don't show it - the ManagedService's updated() just has vague comments saying to "apply configuration from config admin" when it is passed a non-null Dictionary.
So then I look here:
http://blog.osgi.org/2010/06/how-to-use-config-admin.html
In there, it seems like maybe they're doing what I guessed. They seem to have moved the actual app from BundleActivator to ManagedService, and are dealing with starting it when updated() receives non-null configuration, stopping it first if it's already started.
But now what about when the BundleActivator's stop() gets called?
Back on the first example page that I mentioned above, they unregister the ManagedService. On the second example page, they don't show what they do.
So I'm guessing maybe unregistering the ManagedService will cause null configuration to be sent to ManagedService.updated(), at which point I can interrupte the app thread, wait for it to end, and then return?
I suspect that I'm thoroughly incorrect, but I don't know what the "real" way to do this is. Thanks in advance for any help.
BundleActivator (BA) and ManagedService (MS) are callbacks to your bundle. BundleActivator is for the active state of your bundle. BA.start is when you bundle is being started and BA.stop is when it is being stopped. MS is called to provide your bundle a configuration, if there is one, or notify you there is no configuration.
So in BA.start, you register your MS service and return. When MS is called (on some other thread), you will either receive your configuration or be told there is no configuration and you can act accordingly (start app, etc.)
Your MS can also be called at anytime to advice of the modification or deletion of your configuration and you should act accordingly (i.e. adjust your app behavior).
When you are called at BA.stop, you need to stop your app. You can unregister the MS or let the framework do it for you as part of normal bundle stop processing.
I have installed the sfErrorNotifierPlugin. When both options reportErrors/reportPHPErrors reportPHPWarnings/reportWarnings are set to false, everything is ok. But I want to catch PHP exceptions and warnings to receive E-mails, but then all my tasks fail, including clear-cache. After few hours of tests I'm 100% sure that the problem is with set_exception_handler/set_error_handler.
There's a similar question:
sfErrorNotifierPlugin on symfony task but the author there is having problems with a custom task. In my case, even built-in tasks fail.
I haven't used sfErrorNotifierPlugin, but I have run into 'The “default” context does not exist.' messages before. It happens when a call is made to sfContext::getInstance() and the context simply doesn't exist. I've had this happen a lot from within custom tasks. One solution is to add sfContext::createInstance() before the call to sfContext::getInstance(). This will ensure that a context exists.
There's an interesting blog post on 'Why sfContext::getInstance() is bad' that goes into more detail - http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/
Well, the problem could not be solved this way, unfortunately. Using sfErrorNotifierPlugin, I have enabled reporting PHP warning/errors (apart from symfony exceptions) and this resulted in huge problems, e.g. built-in tasks such as clear-cache failed.
The solution I chose was to load the plugin only in non-task mode (project configuration class):
public function setup()
{
$this->enableAllPluginsExcept('sfPropelPlugin');
if ('cli' == php_sapi_name()) $this->disablePlugins('sfErrorNotifierPlugin');
}
WHen a task is executed, everything works normally. When an app is fired from the browser, emails are sent when exception/warning occurs (maybe someone will find it useful).
Arms has explained the problem correctly. But usually context does not exist when executing backend/maintenance tasks on the console. And it is easier if you handle the condition yourself.
Check, if you really need the context?
If you do, what exactly do you need it for?
Sometimes you only want a user to populate a created_by field. You can work around by hard-coding a user ID.
If you want to do something more integrated, create a page (which will have a context) and trigger the task from there.
you can test the existance of the instance before doing something inside a class. Like:
if(sfContext::hasInstance())
$this->microsite_id = sfContext::getInstance()->getUser()->getAttribute('active_microsite');
I've been experiencing the same problem using the plugin sfErrorNotifier.
In my specific case, I noticed a warning was raised:
Warning: ob_start(): function '' not found or invalid function name in /var/www/ncsoft_qa/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 155
Notice: ob_start(): failed to create buffer in /var/www/ncsoft_qa/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 155
So, checking the file: sfApplicationConfiguration.class.php class, line 155,
I've replaced the ' ' for a null, then the warnings disappears, and also the error!
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); bad
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null); good
I promise this isn't as simple as it sounds. I'm wondering why the the first ever call to HttpSendRequest takes much longer than subsequent calls, even when the later requests are for a different URL. For example:
InternetConnect(... "foo.com" ...) // returns immediately
HttpOpenRequest(...) // returns immediately
HttpSendRequest(...) // takes ~3 sec
HttpSendRequest(...) // takes ~200 ms
InternetConnect(... "bar.com" ...) // returns immediately
HttpOpenRequest(...) // returns immediately
HttpSendRequest(...) // takes ~200 ms
Why does the first HttpSendRequest(...) take so much longer? This is very consistent, regardless of the URLs.
Thanks,
Greg
There are several things that may need to happen on the first request that don't need to happen on the second. DNS lookup and proxy detection immediately come to mind.
It could also be config file loading. Some of the .Net framework classes will attempt to read settings from the application config file, revertign to defaults if no file or setting is found. E.g. WebRequest/WebClient which I think are Http classes use under the hood will check for explicit web proxy settings, if those don't exist then then proxy setting from the OS (as set within IE) are picked up. Allof this contributes to an initial startup lag usually when the class is first used, that is, the work is often done in within a static contructor.
The config settings are defined here:
Configuration File Schema for the .NET Framework