Why is subclassing goog.ui.Button producing this error? - google-closure-library

I made a subclass of goog.ui.Button in my Google Closure javascript.
/**
* #fileoverview This button makes a new widget.
* #author David Faux
*/
goog.provide('app.ui.NewWidgetButton');
goog.require('goog.ui.Button');
/**
* Button for creating a new widget.
* #constructor
* #param {goog.ui.ButtonRenderer=} opt_renderer Optional renderer used to
* render or decorate the button.
* #param {goog.dom.DomHelper=} opt_domHelper Optional DOM hepler, used for
* document interaction.
* #extends {goog.ui.Button}
*/
app.ui.NewWidgetButton = function(opt_renderer, opt_domHelper) {
goog.base(
this,
/** #type {goog.ui.ControlContent} */ 'New Widget',
opt_renderer,
opt_domHelper);
}
goog.inherits(app.ui.NewWidgetButton, goog.ui.Button);
However, when I instantiate this button with var newButton = app.ui.NewWidgetButton();, I get an error in Chrome Console:
`Uncaught TypeError: Object #<Object> has no method 'setContentInternal'`
I looked up the method setContentInternal, and it seemed to be a method of the class goog.ui.Control, which is a superclass of goog.ui.Button, so I am befuddled as to why this method is undefined.

The instantiation of newButton is missing the new keyword. Adding the new keyword fixes the error.
var newButton = new app.ui.NewWidgetButton();
Set the Closure Compiler flag --warning_level=VERBOSE to generate an error such as the following:
WARNING - Constructor function (new:app.ui.NewWidgetButton, (goog.ui.ButtonRenderer|null)=, (goog.dom.DomHelper|null)=): undefined should be called with the "new" keyword

Related

Overriding property name in Api Platform

Oke, so I have the following use case. On some of my entities I use a file entity for example with the organization logo.
Now I want users to post either a link (I will then async get the file) or a base64 has of the file. But when the user does a get I want to present an JSON representation of the file entity (that also includes size, a thumbnail link etc).
The current setup that I have is two different properties on my entity, one for reading and one for posting with different logic. And then an event listener that handels the logic. That’s all fine and all but it causes the user to post a postLogo property in their json file, I would hower like them to post to a logo property in their json file.
Is there an annotation that I can use (for example name on ApiProperty) to achieve this or do I need to override the serializer?
/**
* #var File The logo of this organisation
*
* #ORM\ManyToOne(targetEntity="File")
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="#/components/schemas/File"
* }
* }
* )
* #Groups({"read"})
*/
public $logo;
/**
* #var string The logo of this organisation, a logo can iether be posted as a valid url to that logo or a base64 reprecentation of that logo.
*
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="url or base64"
* }
* }
* )
* #Groups({"write"})
*/
public $postLogo;
You can add a setter with a SerializedName annotation. Something like this should work
/**
* #Groups({"write"})
* #SerializedName("logo")
*
*/
public function setPostLogo($value)
{
$this->postLogo = $value;
}

Which observers are called when click on edit button on magento cart?

I have create a observer, before edit button click event are occurred.
using this I could change the value of select box
For an observer to be called, two things should exist, an event and an $observer which listens to that event. To set an observer on an event simply google, you will find out how.
If you wanna debug your observer,there are two important methods you can watch to understand what's going on. The first one is Mage_Core_Model_App#dispatchEvent at app/code/core/Mage/Core/Model/App.php:1271
public function dispatchEvent($eventName, $args)
{
$eventName = strtolower($eventName);
foreach ($this->_events as $area=>$events) {
// (...)
This is where all events has a stop on their way. During development, you can inspect the $eventName by setting a breakpoint here (my favorite), logging the value to a file, or even get very dirty and simply echo to see under the hood.
public function dispatchEvent($eventName, $args)
echo "BlaBlaBla"; // just used to find the printed lines in view source code of browser
print_r($eventName);
$eventName = strtolower($eventName);
foreach ($this->_events as $area=>$events) {
// (...)
Remember, you are editing core files, and this is just to explore and find the event name, get rid of these lines afterwards.
The second method which actually does the job is Mage_Core_Model_App#_callObserverMethod at app/code/core/Mage/Core/Model/App.php:1338
/**
* #param object $object
* #param string $method
* #param Varien_Event_Observer $observer
* #return Mage_Core_Model_App
* #throws Mage_Core_Exception
*/
protected function _callObserverMethod($object, $method, $observer)
{
if (method_exists($object, $method)) {
$object->$method($observer);
} elseif (Mage::getIsDeveloperMode()) {
Mage::throwException('Method "'.$method.'" is not defined in "'.get_class($object).'"');
}
return $this;
}
$object->$method($observer) will call the observer method on an object, just like before you can set a breakpoint, log to a file or even echo to see what's going on under the hood.
First find the event you are interested in, then try to add bind the event to the observer then, if not working, you can use the second method to debug.
And, yay.... Magento is never simple.

Typo3 extbase validating custom or manual objects

I have created extbase extension, there for some reason I need to create object manually in create action.
My create action looks like this,
/**
* action create
*
* #return void
*/
public function createAction() {
$newObj = new \TYPO3\Myext\Domain\Model\Modelname();
$newObj->setMyval('value');
$this->myrepository->add($newObj);
}
Here the problem is its not validating for require field, captcha etc even if I mention #validate NotEmpty in model.
So how to make the validation of manually created object ?
It should throw error to form like out-of-the-box features.
Thank you.
Out of the box validation is only triggered on constructing model objects from GET/POST parameters according to your controller actions signature.
It should look something like this:
/**
* action create
* #param \TYPO3\Myext\Domain\Model\Modelname $newObject
* #return void
*/
public function createAction(\TYPO3\Myext\Domain\Model\Modelname $newObject) {
$this->myrepository->add($newObj);
}
Take a look at the extension_builder, create a model and let the new/create action be generated for you. That will give you a good example on the create action as well as on the new action where the form is being rendered.

Find error line in AngularJS app

I just started to play with AngularJS and I got error below.
Error: Argument '?' is not a function, got Object
at assertArg (http://localhost/angular/project/scripts/vendor/angular.js:1039:11)
at assertArgFn (http://localhost/angular/project/scripts/vendor/angular.js:1049:3)
at http://localhost/angular/project/scripts/vendor/angular.js:4802:9
at http://localhost/angular/project/scripts/vendor/angular.js:4384:17
at forEach (http://localhost/angular/project/scripts/vendor/angular.js:137:20)
at nodeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4369:11)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4015:15)
at compositeLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:4018:13)
at publicLinkFn (http://localhost/angular/project/scripts/vendor/angular.js:3920:30)
at update (http://localhost/angular/project/scripts/vendor/angular.js:14202:11)
Now, my question is: Is there a way I can find line in .js file where error occurred?
I get line number in angular.js file on raised exception but there is too many files where
error can occur.
I tried with AngularJS Batarang, but this is more for debugging semantic not syntax errors.
Thanks.
It'll be easier if you link to the js files that would have caused this error.
From the angular.js source, https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js
it looks like a problem with instantiating the controller.
Here's the line that's causing assertion failure:
/**
* #ngdoc function
* #name ng.$controller
* #requires $injector
*
* #param {Function|string} constructor If called with a function then it's considered to be the
* controller constructor function. Otherwise it's considered to be a string which is used
* to retrieve the controller constructor using the following steps:
*
* * check if a controller with given name is registered via `$controllerProvider`
* * check if evaluating the string on the current scope returns a constructor
* * check `window[constructor]` on the global `window` object
*
* #param {Object} locals Injection locals for Controller.
* #return {Object} Instance of given controller.
*
* #description
* `$controller` service is responsible for instantiating controllers.
*
* It's just a simple call to {#link AUTO.$injector $injector}, but extracted into
* a service, so that one can override this service with {#link https://gist.github.com/1649788
* BC version}.
*/
return function(constructor, locals) {
if(isString(constructor)) {
var name = constructor;
constructor = controllers.hasOwnProperty(name)
? controllers[name]
: getter(locals.$scope, name, true) || getter($window, name, true);
======> assertArgFn(constructor, name, true);
}
return $injector.instantiate(constructor, locals);
};
It's unable to find the constructor for the controller.

code asistant comment style

I try to make use of code assistant in Aptana.
It seems that it is not working with js self written code, or I'm using it the wrong way.
I'm working with Aptana Studio 3, build: 3.2.2.201208201020
I comment my javascript like so:
/**
Simple utilities like alert/info/error windows etc.
#constructor
#param object params - set of key:value properties
*/
function SomeClass(params)
{
/**
* #var some description
*/
this.messages = [];
/**
* My function
*
* #param string some_param - some description
*/
this.somefunction = function(some_param)
{
//some code
}
}
Now when I type this. in SomeClass block a popup shows and i can find messages and somefunction but it say that both have no description.
When I'm in this.somefunction section I get proposals for global variables like window.location but no help for this. nor for SomeClass
I'm using this comment style in php and it works like a charm.
What am I doing wrong? This JS comment style was working in my previous eclipse - helios.

Resources