qooxdoo new property not visible in log tool - properties

I am checking an instance of a qooxdoo class using console.log('%o', inst).
Here the properties are shown with leading "$$user..." marks.
But when adding a new property to the class, it is not shown in the console.log-output.
The code is running using the new property; so the syntax and class structure is ok. I checked in release and debug mode.
What do I have to do to see the new property also in the console.log output ?
Or is there something cached so it will not be shown until a certain refresh ?

Qooxdoo uses $$user_ to store the current, user provided, property value. The $$user_ values are only set if the property has been actively set after the object properties are constructed during class initialization.
Having some kind of init value is not enough, so you've to put something in there actively to make them visible in the console.log call above.
The init values are stored in the prototype as $$init_ followed by the variable name. So
qx.Class.define("foobar", {
extend: qx.core.Object,
properties: {
test1 : {},
test2 : {init: 5}
}
});
will result in no single $$user_test1 or $$user_test2 directly after you initialized the class. If you call setTest2(99), you'll see that $$user_test2 shows up in the console - and it disappears if you call resetTest2().
To answer the question: you can only enforce having $$user_ values to be set, by putting someting in actively. Or better define a watch in your chrome console that calls getTest2() on the watched object.

Related

How to add modernizr build so that I can properly check Modernizr.capture? (currently always undefined)

I need to check if the user's device can input from a camera on my site. To do this I am attempting to use modernizr. I have followed the steps/example code provided on their site but when I test the capture attribute, I always get undefined, regardless of if I am on a device that supports capture.
Steps I followed:
I browsed for the input[capture] attribute and added it to the build
I copied the demo code to check this feature and added it to my project
I downloaded the build, added the js file to my project, and included the appropriate reference in my page
However after all of this, when inspecting Modernizr.capture in the chrome inspector, it always shows up as undefined.
My basic check function is as follows:
$scope.hasCamera = function() {
if (Modernizr.capture) {
// supported
return true;
} else {
// not-supported
return false;
}
}
This is my first time using Modernizr. Am I missing a step or doing something incorrectly? I also installed modernizr using npm install and tried adding the reference to a json config file from the command line.
Alternatively, how might I check if my device has a camera?
Thank you very much for your time. Please let me know if I am being unclear or if you need any additional information from me.
A few things
while photos are helpful, actual code hosted in a public website (either your own project, or on something like jsbin.com) is 10x as useful. As a result, I am not sure why it is coming back as undefined.
The actual capture detect is quite simple. It all comes down to this
var capture = 'capture' in document.createElement('input')`
Your code is a lot more complicated than it needs to be. Lets break it down. You trying to set $scope.hasCamera to equal the result of Modernizr.capture, and you are using a function to check the value of Modernizr.capture, and if it is true, return true. If it is false, return false. There is a fair bit of duplicated logic, so we can break it down from the inside out.
Firstly, your testing for a true/false value, and then returning the same value. That means you could simplify the code by just returning the value of Modernizr.capture
$scope.hasCamera = function() {
return Modernizr.capture
}
While Modernizr will always be giving you a boolean value (when it is functioning - without seeing your actual code I can't say why it is coming back as undefined), if you are unsure of the value you can add !! before it to coerce it into a boolean. In your case, it would make undefined into false
$scope.hasCamera = function() {
return !!Modernizr.capture
}
At this point, you can see that we are setting up a function just to return a static value. That means we can just set assign that static value directly to the variable rather than setting up a function to do that
$scope.hasCamera = !!Modernizr.capture
Now, the final thing you may be able to do something better is if you are only using Modernizr for this one feature. Since it is such a simple feature detection, it is overkill to be using all of Modernizr.
$scope.hasCamera = 'capture' in document.createElement('input')`

Get pluginId stored in the IPreferenceNode in Eclipse

I am developing a plugin, in my plugin I want to get another plugin ID. I use the following code:
PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
List<IPreferenceNode> list = pm.getElements(PreferenceManager.PRE_ORDER);
String pluginid;
// restoreDefValues("org.eclipse.ant.ui");
for(IPreferenceNode node : list){
the code to find the node related to the plugin;
}
When I debug the program, I can clearly see that in variable node(IPreferenceNode), it has the value of the pluginId. However, I check the document of IPreferenceNode, it seems that the neither IPreferenceNode nor the class PreferenceNode, provide a method to return the value of pluginId. I tried node.toString() as well, couldn't get the pluginId. So what should I do? Is there any other ways to get a plugin ID from another plugin?
Preference nodes created using the org.eclipse.ui.preferencePages extension point will actually be instances of org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode. The super class of this (WorkbenchPreferenceExtensionNode) contains the plugin id.
These classes are internal so you should not try to use them directly. However they implement org.eclipse.ui.IPluginContribution which can be used and has a getPluginId() method.
So something like:
if (node instanceof IPluginContribution) {
pluginId = ((IPluginContribution)node).getPluginId();
}
should work.

Sencha Touch 2 store is loaded multiple time [Maximum call stack size exceeded]

I'm having a weird problem with the Sencha Touch 2 Store class. Here is what I have:
A simple view PollsList that defines a list view (with a store attribute set to Polls). I've included the required store as follow: requires:['Polls'],
A store class Polls with a model attribute set to Poll and a dummy data attribute,
A model class named Poll (the simplest possible),
An app.js file with the following launch methode:
var pollsListView = Ext.create('PollsList');
Ext.Viewport.add(pollsListView);
Ext.Viewport.setActiveItem(pollsListView);
I've also included the stores: ['Polls'] declaration in the app.js as required.
Now, the weird thing is when I access the PollsList view, the Poll store is being loaded indefinitely, till I got a the following error:
Uncaught RangeError: Maximum call stack size exceeded sencha-touch.js:598
And the stack seems to loop on the following calls:
Ext.ClassManager.instantiate sencha-touch.js:6378
(anonymous function) sencha-touch.js:3198
(anonymous function) app/store/Polls.js:4
Ext.apply.globalEval sencha-touch.js:598
Ext.apply.globalEval sencha-touch.js:599
Ext.apply.loadScriptFile sencha-touch.js:7673
Ext.apply.require sencha-touch.js:7831
Ext.apply.syncRequire sencha-touch.js:7695
(anonymous function)
Any idea?
Seems weird, done many a times, but did not went wrong.
Any ways, try removing the setActiveItem as there is only one view and it will take it as active.
Remove the require line from the code, as it seems that currently it is not required though.(Just because i want to make this sample running).
Now, try initializing the store, as
var store = Ext.create("YourStore") //
var listControl = Ext.craeate("YourList" ,{store : "aboveCreatedStore" , ..... });
listControl.setData( {name :'hello'} ); // hoping the model is having one String type field
Ext.ViewPort.add(listControl);
Thats it...
The above given code is not a complete solution(its like a patch), but it is to make you know what wrong you are doing in your current code.

Ninject: More than one matching bindings are available

I have a dependency with parameters constructor. When I call the action more than 1x, it show this error:
Error activating IValidationPurchaseService
More than one matching bindings are available.
Activation path:
1) Request for IValidationPurchaseService
Suggestions:
1) Ensure that you have defined a binding for IValidationPurchaseService only once.
public ActionResult Detalhes(string regionUrl, string discountUrl, DetalhesModel detalhesModel)
{
var validationPurchaseDTO = new ValidationPurchaseDTO {...}
KernelFactory.Kernel.Bind<IValidationPurchaseService>().To<ValidationPurchaseService>()
.WithConstructorArgument("validationPurchaseDTO", validationPurchaseDTO)
.WithConstructorArgument("confirmPayment", true);
this.ValidationPurchaseService = KernelFactory.Kernel.Get<IValidationPurchaseService>();
...
}
I'm not sure what are you trying to achieve by the code you cited. The error is raised because you bind the same service more than once, so when you are trying to resolve it it can't choose one (identical) binding over another. This is not how DI Container is supposed to be operated. In your example you are not getting advantage of your DI at all. You can replace your code:
KernelFactory.Kernel.Bind<IValidationPurchaseService>().To<ValidationPurchaseService>()
.WithConstructorArgument("validationPurchaseDTO", validationPurchaseDTO)
.WithConstructorArgument("confirmPayment", true);
this.ValidationPurchaseService = KernelFactory.Kernel.Get<IValidationPurchaseService>();
With this:
this.ValidationPurchaseService = new ValidationPurchaseService(validationPurchaseDTO:validationPurchaseDTO, confirmPayment:true)
If you could explain what you are trying to achieve by using ninject in this scenario the community will be able to assist further.
Your KernelFactory probably returns the same kernel (singleton) on each successive call to the controller. Which is why you add a similar binding every time you hit the URL that activates this controller. So it probably works the first time and starts failing after the second time.

"apply is not a function" when using dojo.connect with an item of dijit.WidgetSet

I have a set of dijit.form.CheckBoxe(s) on myJSP.jsp.
In my dojo class myClass.js, I try to grab these checkboxes and connect to each of them a function which should be called on an "onClick" event:
(dijit.registry.byClass("dijit.form.CheckBox")).forEach(function(checkBox){
dojo.connect(checkBox,"onClick",this,this.checkboxClicked);
});
When I click on any of the checkboxes, I get the following message: "lls[i].apply is not a function".
Why can't I use dojo.connect?
Btw - I use IBM Websphere Portal 6.1.5's dojo version, which is 1.3.2.
The cause is that this in the forEach callback function actually refers to the global object and this.checkboxClicked is actually undefined.
To fix that, use the second parameter in the forEach function to specify the scope object, i.e. the this object.
Below code may work depends on whether the this object when invoking this function is the same one that has the checkboxClicked function. If it's not, you can change to use other object.
(dijit.registry.byClass("dijit.form.CheckBox")).forEach(function(checkBox){
dojo.connect(checkBox,"onClick",this,this.checkboxClicked);
}, this);