RSS

Monthly Archives: July 2013

Rendering HTML Code with DJANGO and DOJO

One of the things that I like about dojo is the django rendering engine. It provides an easy way to build HTML Templates and let you render values form a json object. The following example of a template is used to loop through a json array response.

<div>
{% for entry in feed.entries%}
<div style=”height: auto;”>
<div>
<div>{{entry.created}}</div>
<h2>
<a target=”_blank” href=”{{entry.link}}”>{{entry.title}}</a>
</h2>
</div>
<div>
<div>
{{entry.content|safe}}
</div>
</div>
</div>
{%endfor%}
</div>

This code is used in the dojo widget:

dojo.provide(“xptrss.list.feedcontroller”);
dojo.require(“dijit._Widget”);
dojo.require(“dojox.dtl._Templated”);
dojo.declare(“xptrss.list.feedcontroller”, [ dijit._Widget, dojox.dtl._Templated ], {
proxyurl:null,
feed : null,
templateString : dojo.cache(“xptrss.list.feedcontroller”,    “../../html/rssTemplate.html”),
targetid: null,
postCreate: function() {
var mySelf = this;
var xhrArgs = {
url : mySelf.proxyurl,
handleAs : “json”,
preventCache : true,
load : function(data) {
mySelf.feed = data;
mySelf.render();
dojo.style(mySelf.targetid +”_feedLoader”, {
display : “none”
});
},
error : function(error) {
alert(error);
}

}
var deferred = dojo.xhrGet(xhrArgs);
}

});

With the statement  templateString : dojo.cache(“xptrss.list.feedcontroller”,    “../../html/rssTemplate.html”) the html will be loaded. The “postCreation()” handles the loading of the values. With “mySelf.render()” the loaded JSON object will be applied to the HTML Template and the django engine loops through all entries and applies the code between {% for …. } {%endfor%} for each entry.

But what if an element in an entry (like the content value) is pure HTML Code?

The django engine is so clever and escapse all content correct, but we need the content unescaped in this particular case. The statement  {{entry.content|safe}} does the trick!

This is code from our new project XPages Toolkit.

 
Leave a comment

Posted by on July 19, 2013 in Domino, Java, XPages

 

Breaking through the “idiot-centric” paradigm

At the “socialconnections V” I did a word creation. But to be honest, I don’t belive, that this word creation is my ownership. I call it “idiotic-centric” paradigm.

The idiotic-centric paradigm

It describes whats usually happen in a company, or an organisation, when something goes wrong. It describes our normal behavior on broken processes, wrong results and disappointing interruption.

We do first try to find the responsible person. We investigate much of our time to find the responsible “idiot” that we can blame. Instead according to the Eisenhover-Methode, we should be focused on solving the issue, because we are loosing time and the problem grows.

But is not every problem a great opportunity? Yes its annoying and disappointing, when things go wrong. In every area of my life, I learned most from my mistakes and the problems I was faced. Seeing unexpected problems (yes there are mostly unexpected) as a place to learn, a place where new heroes can be born, is a good way to challenge and engage yourself, your manager and your employees.

Breaking through the idiotic-centric paradigm is hard, because finding the idiot is much easier than solving the issue. Imagin this: There is an accident on the road. People are badly hurt or dying.  And the ambulance does  nothing but try to find the reasponsible.  A horror-scenario? Definitely, but this is our normal behavior in most situations!

See in the next problem your great opportunity to change your behavior!

 
Leave a comment

Posted by on July 1, 2013 in Leadership, SocialBusiness