[Laszlo-dev] LzDataset setSrc nulls query string in OL4.0.6?

P T Withington ptw at pobox.com
Fri Oct 19 05:07:27 PDT 2007


[Adding the doc guys...  And the guy who implemented this -- am I  
telling the truth Henry?]

This is intended behavior, but maybe it needs better documentation.   
The old interface was ill-defined as to how the 3(!) interfaces to  
dataset parameters interacted.  This is the current intent:

The dataset `src` property is stored as an LzURL.  If set to a  
string, it is parsed into an URL.  If you want to change the query,  
you can get the src URL using `getSrc`, adjust the query part of the  
URL, and set it back using `setSrc`.

`getQueryString` is simply a shortcut to the query part of the src  
URL, updated when the URL is.

`setQueryString` is simply a shortcut to update the src URL with a  
new URL with the query replaced by the argument.

Similarly for `getQueryParams` and `setQueryParams`, except they deal  
in LzParams instead of strings.

Thus, everything is really operating on the src URL, so there is no  
amgbiguity as to how merging happens.  (If you want merging, get the  
queryparams object, manipulate it, and put it back), e.g.:

var parms = <dataset>.getQueryParams();
// for each parameter you need to add
parms.addValue(<key>, <val>);
// Replace the query with the updated parameters
<dataset>.setQueryParams(parms);

On 2007-10-19, at 06:35 EDT, David Russell wrote:

> While porting an app from 3.3.3 to 4.0.6 I've come across some  
> unexpected behaviors using LzDataset.
>
> The original app would prepare a doRequest() on a dataset as follows:
>      dset.setQueryString(params);
>    dset.setSrc(serverUrl);
>    dset.doRequest();
>
> This works fine under 3.3.3.
>
> It seems in 4.0.6 the call to dset.setSrc(serverUrl) has a new  
> consequence, it sets the datasets querystring to null.
>
> The eventual doRequest() call then fails on the server side for  
> want of required parameters. By revising the call order to have the  
> setSrc(serverUrl) called first followed by the setQueryString 
> (params) things work once more.
>
> In 4.0.6 this can be observed whether deploying swf or dhtml and  
> whether one dynamically instantiates the LzDataset or use a  
> declared dataset.
>
> I attach a very simple test case, don't worry if the final call  
> fails  the issue is concerned with what is going on in the dataset  
> on the client before the call.
>
> I'm not sure if this is new intended behavior (?) or a regression.  
> Can anyone shed any light?
>
> Thanks, David
> <canvas width="100%" height="100%" debug="true">
>
>   <script>
>
>     var dset =
>       new LzDataset(canvas, {name:"dynads", request: false,  
> type:"http"});
>
>     var params = new LzParam();
>     params.addValue("method", "someMethod");
>     dset.setQueryString(params);
>
>     Debug.write("getQueryString(1)=", dset.getQueryString());
>
>     // Inspect the dataset and observe the valid querystring  
> property...
>     Debug.inspect(dset);
>
>     var server = "http://localhost:8080/lps-4.0.6/controller";
>     dset.setSrc(server);
>
>     Debug.write("getQueryString(2)=", dset.getQueryString());
>
>     dset.doRequest();
>
>     // Inspect the dataset and observe the null querystring  
> property...
>     Debug.inspect(dset);
>
>   </script>
>
> </canvas>



More information about the Laszlo-dev mailing list