Thanks very much indeed for the clarification Adam - I wasn't aware of the need
for the *. That's much tidier and faster now. I also had to update the
xPathQuery from this.xpathQuery("result/text()") to read
(this.xpathQuery("text()"), but it's working wonderfully, thanks.
Perhaps I should also point out why I'm realying data this way. As I understand
it, the documented way (here:
http://www.laszlosystems.com/lps-3.2/docs/guide/data_app.html#d0e22386 )
manages the update to the database via JSP, and then updates the local dataset
by adding a node with the new entry information. These are two independent
processes, as far as I can tell, which is fine if the database updates
successfully. However, if the DB update fails (rare but possible), the local
dataset will still update with the new information, resulting in a view that's
out of sync with the database, and now supplying false information to the user.
(If I'm wrong, please let me know!)
The way I've done it with my datapipe class (see below) means that updating the
view becomes success/failure based - if the trip to the database fails, the
display doesn't update, and an error or timeout message could be displayed. (Of
course, this is at the cost of an extra trip to the database, but I think it's
worth it to keep everything in sync.) I can elaborate further on how this works
if needs be with an example.
I'd appreciate people's thoughts on this, and whether there's a middle ground
that could result in only a single trip whilst keeping data in sync.
Thanks again for the help all.
>Sorry I didn't see your question earilier. Before, you wrote:
>> <datapointer name = "dp" xpath="local:list:/">
>
>This binds the datapointer to the dataset itself. It will not run ondata
>or receive updates when the dataset loads data because the result of its
>xpath expression doesn't change. I think that instead you want to write:
> <datapointer name = "dp" xpath="local:list:/*">
>
>This will run ondata only when the local:list dataset loads data.
>
>
>A
>
>On May 2, [EMAIL PROTECTED] wrote:
>
>>
>> Just to let you know that I finally got my datapipe class working as expected
>> - thanks a lot for everyone's help. The trick was to reassign the
>> datapointer's xpath attribute at the end of the ondata method. (4th line from
>> the end). This forces it to update the second time data is received, and not
>> just the first time.
>>
>> <class name = "datapipe" extends = "node">
>> <attribute name = "table" type = "string" />
>> <dataset name="getrecords" type="http" request = "false" />
>> <dataset name="action" type="http" request = "false" />
>>
>> <method reference = "action" event="ondata">
>> dp.setXPath("local:action:/");
>> </method>
>>
>> <datapointer name = "dp">
>> <method event="ondata">
>> if (this.xpathQuery("result/text()") == "success") {
>> parent.getrecords.doRequest();
>> Debug.write("Operation succeeded");
>> } else {
>> Debug.write("Operation failed");
>> }
>> this.setXPath("local:getrecords:/");
>> </method>
>> </datapointer>
>> </class>
>>
>> The result is a canvas where all dynamic data automatically updates to stay
>> in
>> sync with the table records whenever the database is updated.
>>
>> Thanks again for your help.
>>
>>
>> On 1 May 2006, at 18:27, Henry Minsky wrote:
>>
>> > I believe an empty local datset will be created by the <dataset>
>> > declaration. That is, it will have no child elements. There may be some
>> > issue with how you are generating the ondata events. When I did this
>> > manually from the debugger, the xpath query worked fine.
>> >
>> > <class name = "datapipe" extends = "node">
>> > <attribute name = "table" type = "string" />
>> > <dataset name="action" type="http" request = "false" />
>> > <datapointer name='bar' xpath="local:action:/">
>> > <method event="ondata">
>> > var q = "results/text()";
>> > Debug.write(q, this.xpathQuery(q));
>> > </method>
>> > </datapointer>
>> > </class>
>> >
>> > <datapipe id='foo'/>
>> >
>> >
>> > In the debugger, I did this manually
>> >
>> > lzx> k = new LzDataElement("results")
>> > ?LzDataElement#3| <results/>?
>> > lzx> c = new LzDataText("success!")
>> > ?LzDataText(0)#4| []?
>> > lzx> k.appendChild(c)
>> > ?LzDataText(0)#4| []?
>> > lzx> foo.action.appendChild(k)
>> > ?LzDataElement#3| <results>success!</results>?
>> > lzx> foo.bar
>> > ?LzDatapointer#0| <action><results>success!</results></action>?
>> > lzx> foo.bar.ondata.sendEvent()
>> > results/text() success!
>> > lzx>
>> >
>> >
>> > You're right there - the 'action' dataset is intended as a
>> > 'placeholder' that I can
>> > route requests through from the main canvas. The idea is that
>> > requests are
>> > fed through the action dataset and an updated set of records is
>> > returned via
>> > the 'list' dataset on successful submission. This in turn
>> > automatically updates
>> > any views bound to the list dataset.
>> >
>> > So there's no actual location for the action dataset until a request
>> > is made from
>> > the canvas - this was my intention, but I appreciate it's not the
>> > traditional method.
>> >
>> > Any other thoughts would be warmly received.
>> > http://rafb.net/paste/results/eh2soq66.html
>> >
>> >
>> >
>> > > > I'm having trouble referencing a dataset from within a class.
>> > > >
>> > > > The code here: http://rafb.net/paste/results/eh2soq66.html produces
>> > > > the error "couldn't find dataset for action:/" (Line 13 is where it's
>> > > > referenced.)
>> > > >
>> > > > Would anyone be kind enough to suggest what I should do to correct
>> > > > it?
>> >
>>
>
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user