View Full Version : loading images defined in an xml-file
m.weidemann
04-27-2004, 04:48 AM
Hi,
i would like to load an image in a view. The imagename ist defined in a xml file. here my attempt so far:
<class name="student" >
<view datapath="student[@id='00001']" clickable="true">
<simplelayout axis="y" spacing="2"/>
<view fgcolor="#2f3d51">
<simplelayout axis="x" spacing="2"/>
<text fgcolor="red" >Name:</text>
<text datapath="@name"/>
</view>
<view fgcolor="#2f3d51">
<simplelayout axis="x" spacing="2"/>
<text >Fehltage:</text>
<text datapath="@fehltage"/>
</view>
<view id="studentpic" resource="$path{'@photo'}" />
<method event="onclick">
Debug.write("student click ");
var mypic = 'student0005.PNG';
studentpic.setSource(mypic);
</method>
</view>
</class>
-----------
everything works fine, but there is no image.
why does resource="$path{'@photo'}" not work (the xml an xpath is correct) ?
i tried to load the image in an "onload" event, but this event does not occure, that's why i put it in an "onclick" event. when i click on the view i get the following debug messages, that confuses me finally :)
student click
«string#0| java.text.ParseException: Unparseable date: "Tue, 27 Apr 2004 12:17:16
whats wrong ?
Thank you
markus
antun
04-27-2004, 09:09 AM
everything works fine, but there is no image.
why does resource="$path{'@photo'}" not work (the xml an xpath is correct) ?
This can be confusing, I agree. To set a view's resource at run-time, use view's setSource() method:
<view id="studentpic" datapath="@photo">
<method event="ondata" args="d">
this.setSource( d );
</method>
</view>
The ondata event is fired when the data that the view's datapath is pointing to changes.
You typically would use resource for images that you know up front. For example your application chrome, as well as images loaded at run-time whose URLs you know at compile-time.
Also, you shouldn't use an id in a class definition. id's are global - there can only be one per app. Use name instead.
As for the onload event, that's sent when a view attaches its resource. You might use that to know when a large image has finished loading.
-Antun
m.weidemann
04-28-2004, 01:03 AM
Thank you for your quick answer and tips.
Unfortunately it still doesnt work. when calling this.setSource(d) i get the same parse-exception as told before. The date is the file creation date.
Here ist the java stack trace, as far as the debugger shows it:
«string#0| java.text.ParseException: Unparseable date: "Tue, 27 Apr 2004 12:17:15 GMT" :
Exception stack: com.laszlosystems.utils.ChainedException:
java.text.ParseException: Unparseable date: "Tue, 27 Apr 2004 12:17:15 GMT" at
com.laszlosystems.utils.LZHttpUtils.getDate(LZHttp Utils.java:128) at
com.laszlosystems.data.internal.HTTPDataSource$Htt pData.lastModified(HTTPDataSource.java:482) at
com.laszlosystems.cache.RequestCache.getItemStream AsSWF(RequestCache.java:332) at
com.laszlosystems.cache.RequestCache.getAsSWF(Requ estCache.java:140) at
com.laszlosystems.servlets.responders.ResponderCac he.respondImpl(ResponderCache.java:312) at
com.laszlosystems.servlets.responders.Responder.re spond(Responder.java:207) at
com.laszlosystems.servlets.LZServlet._doGet(LZServ let.java:287) at
com.laszlosystems.servlets.LZServlet.doGet(LZServl et.java:223) at
javax.servlet.http.HttpServlet.service(HttpServlet .java:740) at
javax.servlet.http.HttpServlet.service(HttpServlet .java:853) at
org.apache.catalina.core.Appli...»
m.weidemann
04-28-2004, 01:13 AM
antun
it seems that you have problems with regional settings. since i have changed my settings to english(us), it works fine. I hope you will fix this with future releases.
Markus
antun
04-28-2004, 08:55 AM
Hi Markus
I've filed this as a bug. However we may need some more details in the future.
Thanks you!
-Antun
where do you change your local settings? are they the global settings of the computer or only java settings ?
m.weidemann
05-03-2004, 12:38 AM
I have changed the global windows system settings.
Pixelpusher
05-07-2004, 01:31 AM
setSource() does not work at all for me. I get javaParseExceptions whatever string I put in there.
Absolute URLs
Relative paths
Local or remote...
Nothing works.
The resource attribute in <view> works fine though.
antun
05-07-2004, 08:01 AM
Are you using the default DE install, or did you install the LPS in your own servlet container?
-Antun
Originally posted by Pixelpusher
setSource() does not work at all for me. I get javaParseExceptions whatever string I put in there.
Absolute URLs
Relative paths
Local or remote...
Nothing works.
The resource attribute in <view> works fine though.
Pixelpusher
05-07-2004, 08:04 AM
I am using the standard install and placed all my files in the recommended my-apps folder
No settings changed.
antun
05-07-2004, 08:18 AM
Are you saying that if you save this and run it:
<canvas debug="true">
<debug x="150" />
<simplelayout axis="y" spacing="10" />
<button>Call setSource
<method event="onclick">
foo.setSource( 'http://www.laszlosystems.com/images/smiley.gif' );
</method>
</button>
<view id="foo" />
</canvas>
... you don't see the image?
If you don't see the image, let me know what your OS and JVM version are.
-Antun
Fresh Mike
10-21-2004, 04:33 AM
http://www.laszlosystems.com/developers/community/forums/showthread.php?postid=4649#post4646
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.