PDA

View Full Version : XTemplate and undefinied object



BadMoonKiller
22 Mar 2009, 8:42 AM
Hello Community

I have some problems with the XTemplate. My application works with hibernate.

On the database I have a column firstName, lastName and studyGroup. studyGroup is a foreignkey to another table. Sometimes its value is NULL.

If studyGroup is NULL, the second <p>-element shouldn't be post.

Now, if I run this code i always get a javascript exception, that studyGroup is undefinied, even if I check that in the code below... How can i do that right?

Here ist my template code:


private native String getTemplate() /*-{
return ['<tpl for=".">','<p>{firstName} {lastName}</p>{street}</p>','<tpl if="studyGroup != null">','<tpl for="studyGroup">','<p>{name}</p>','</tpl>','</tpl>','</tpl>'].join("");
}-*/;

BadMoonKiller
29 Mar 2009, 3:14 AM
Does somebody know a solution for my problem?

here is the javascript error:



[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): 'studyGroup' ist undefiniert
number: -2146823279
description: 'studyGroup' ist undefiniert
at com.extjs.gxt.ui.client.core.XTemplate$.overwrite$(Native Method)
at com.extjs.gxt.ui.client.widget.ListView.bufferRender(ListView.java:761)
at com.extjs.gxt.ui.client.widget.ListView.onAdd(ListView.java:632)
at com.extjs.gxt.ui.client.widget.ListView$3.storeAdd(ListView.java:590)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:21)
...