speich.net logo

REST with dojo and PHP: Notes on using dgrid with a caching store

I would like to share some (personal) pitfalls I came across when creating the demo REST with dojo and PHP: Demo of a dgrid observing changes to the JsonRest store:

  • dojo/store/Observable only works correctly when the object has an id. Unfortunately, dojo/store/Memory.add(object) does not add the id to the object when creating it (as of 1.7.1) .  See bugs http://bugs.dojotoolkit.org/ticket/12835 and http://bugs.dojotoolkit.org/ticket/14281. For a fix see changeset http://bugs.dojotoolkit.org/changeset/27072/dojo
  • Observable does neither work correctly (for the reason above?) with a dojo/store/JsonRest nor a dojo/store/Cache, but that doesn’t really matter, because you can use it directly with the dojo/store/Memory instead.
  • As stated in the docs, but easily missed: dojo/store/Cache automatically adds all returned objects from get() and query() calls to the cache, but only get() uses the cache, whereas query() directly uses the master store. If you want the query to come from the cache, directly call query() on the caching store, e.g. dojo/store/Memory.
  • In the demo, the PHP script responds to the GET 2 by returning a Json object with id 2 and to a GET 2/ by returning an array of objects with parent id 2. If you want to query the Memory store for 2′s children, you have to provide an object as an argument, e.g. storeMemory.query({parId: 2}), whereas the JsonRest store expects a string e.g. storeJsonRest.query(’2/’);
  • JsonRest store’s methods do not return the same types as Memory store, which can be confusing…
    storeMemory.add(newObject) returns the id
    storeJsonRest.add(newObject) returns the response from the server (or rather a Deferred providing it)
    …, but makes sense, because it can save an extra round trip to the server.

 

 

Posted in JavaScript, PHP | Tagged , | 4 Comments

Canon vs. Nikon Telephoto Lenses: If weight plays a major role

The table (sortable) and charts on this page may help you decide which telephoto lens to buy if the weight plays a major role.

It is kind of frustrating that the Canon lenses are about half to a full kilo lighter than the Nikon ones if you are an owner of Nikon equipment. For the weight of a Nikon 500mm you get a Canon 600mm…

Posted in Fotografie | Tagged , , | Leave a comment

Canon vs. Nikon Teleobjektive: Wenn das Gewicht eine Hauptrolle spielt

Die Tabelle (sortierbar) und Grafiken auf dieser Seite können als Entscheidungshilfe beim Kauf eines Teleobjektivs dienen, wenn das Gewicht eine Hauptrolle spielt.

Schon erstaunlich, dass die Canon Objektive bei gleicher Lichtstärke rund ein halbes bis ganzes Kilo leichter als die entsprechenden Nikon Objektive sind. Für das Gewicht eines Nikon 500mm bekommt man ein Canon 600mm…

Posted in Fotografie | Tagged , , | Leave a comment

Yay, my first patch to the dojotoolkit got checked in !

While I’ve been working on my remote file explorer I noticed that the dijit tree remembers the state of opened/closed nodes but not of selections. So I filed a bug and created a patch, which got checked in yesterday.

Posted in JavaScript | Tagged , , | Leave a comment

How to read a Mac-formatted disk from Windows

More of a note to myself: Just download and install the free tool HFSExplorer from Catacombae. Then select “Load file system from file”. Please remember you need to be logged in as an administrator on Windows 7 or have elevated privileges to be able to read external USB drives.

Posted in Übrige | Leave a comment

Installing Xdebug on Windows

There is a small catch when installing Xdebug on windows: You need to set the full path of the extension directive in the php.ini, since the default directory is only used for non-zend extensions.

; used only for 'normal' extensions
extension_dir = "C:\Program Files (x86)\PHP\ext"

; still necessary to use full path
zend_extension="C:\Program Files (x86)\PHP\ext\php_xdebug.dll"

; won't work
; zend_extension=php_xdebug.dll
Posted in PHP | Leave a comment

Why I love JetBrains phpStorm II

Here’s another example for the reason why I like phpStorm so much: SQL code assist in the Database Console completes statements either in upper case or lower case depending on how you started typing, not to speak of understanding aliased tables when suggesting column names after typing a dot.

Screenshot: SQL code assist in PhpStorm understands aliased tables.

Posted in Übrige | Tagged , | Leave a comment

Deutsche Lokalisierung von BlueGriffon 1.0

Zusammen mit André Frick habe ich die deutsche Lokalisierung des freien WYSIWYG HTML-Editors BlueGriffon erstellt. Das härteste Stück Arbeit meinerseits war das Übersetzen der Definitionen der WAI-ARIA Rollen: Eine 1:1 Übersetzung war in den seltensten Fällen möglich, dennoch durfte dabei die exakte Bedeutung nicht verloren gehen. Dazu kam noch, dass die Ausgangstexte bereits in der Originalsprache schwierig zu verstehen waren und nicht immer konsistent formuliert sind.

Falls also jemand nach einer deutschen Übersetzung der ARIA Rollen sucht, kann er diese von der Projektseite der DE-Lokalisierung auf github.com herunterladen.

Posted in Übrige | Tagged , | Leave a comment

© 2011 speich.net, Konzept und Programmierung Simon Speich.
Die Artikel auf dieser Seite laufen mit WordPress.