PDA

View Full Version : for prvious question assigning datapath dynamically


mohan
07-29-2003, 11:31 PM
hai antun,
regarding to my previous question, [assigning datapath dynamically],
i am assigning image to the resource like
<view resource="images/picture.jpg" />
but in my real application i stored image as images/picture2.jpg (var char) in mysql database.And also i am reading that image from JSP file (that returns html/xml).That xml (JSP)is something like
<person>
<user id="1" Fname="david" photo="images/picture2.jpg "/>
<user id="2" Fname="fleming" photo="images/picture5.jpg "/>
</person>

Now i want to fetch photo attribute from that jsp file
and assign to the resource attribute of the view using
datapath="dset:/dating[1]/user[1]/@photo
so how can do that

waiting for the resonse
with regards
mohan

antun
07-30-2003, 07:14 AM
You'd use the setSource() method. Here's a simple example, assuming that your data will look like this:

<myrootnode imageurl="mypic.jpg" />

You use the applyData() method which gets called automatically when data is set (in your case when the request is made, and the data comes back). The "http:" bit forces the image to go over HTTP at runtime.


<view datapath="myDS:/myrootnode/@imageurl">
<method name="applyData" args="d">
setSource( "http:" + d );
</method>
</view>


Does that clear things up?

-Antun