How to load data from app engine

One of the most powerful feature of cloudCMS is that it makes querying app engine very simple and generic for all entities. It provides two directives to load any entity from datastore.

<@loadEntity> and <@listEntity> Directive syntax

loadEntity is to load single entity based on Key/ID and "listEntity" loads one or more matching entities based on "Entity Filter" (optional) and in order defined by "Entity Sort" (optional).


 -Load any entity using Key (Web safe string version of Key) :

<@loadEntity kind="addressBook" key="<KeyAsString>" var="myvar"/>

 -Load any entity using Long ID :

<@loadEntity kind="addressBook" id=<longID> var="myvar"/>

Above example will load single entity of kind "addressbook" into variable "myvar". Now you can access all the property of "addressBook" by simply using ${myvar.<propertyName>} syntax.


"listEntity" directive can be used to retrieve list of entities from datastore.

Full syntax,

<@listEntity kind="kind" filter=<list of filters> sort=<list of sort predicates> limit=<limit> offset=<offset> parentKind="<parentKind>" parentId=<long Id> parentKey="<parentKey>" ; myvar, index, count, totalCount>

How to access entity properties


cloudCMS loads entity and all its property to a generic structure and it maintains the type of underlying property. From above examples, if type of "myvar.dob" is datetime you have to use proper Freemarker syntax to access datetime property.
To access datetime field,
Some more examples to access other data types,
Number : ${myvar.age?c} or ${myvar.salary) 
Boolean - ${myvar.isGraduate?string} 
List - <#list myvar.phoneNos as phone>${phone} </#list>

Implicit Properties

Every entity loaded through loadEntity or listEntity has following implicit properties:

Using "type" and "value" hash you can built a custom data viewer or Entity export tool. Our entity export and import tool is using this feature.

blog comments powered by Disqus

Last Modified : Jul 19, 2009 11:59:12 AM