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

Jean-Baptiste BRIAUD jb at briaud.net
Fri Oct 19 12:45:37 PDT 2007


I got the problem too using 4.0.5
That explain the last part of my email. I cut&paste a copy here so you 
don't have to dig OL mailling list :
Temporary workaround : set src again after the querystring.

> Hi the list !
>
> I would like to send over HTTP the content of a dataset. Nothing 
> complex ins't it ?
> But I got problems ... Let me explain :
>    <dataset name="PetCreate1_pet_embeded_ds">
>        <pet
>             animal="aaa"
>             entryDate="aaa"
>             dateBirth="aaa"
>             age="aaa"
>             name="aaa"
>             sex="aaa"
>             streetNumber="aaa"
>             streetName="aaa"
>             code="aaa"
>             town="aaa"
>        </pet>
>    </dataset>
>
> That dataset if mapped via xpath to different text field. (that 
> dataset do not come from HTTP but is hardcoded like that in the lzx.
> Here is the code I use to send the dataset :
>            <handler name="onclick">
>                var ds = PetCreate1_pet_embeded_ds;
>                Debug.write("Seding data ...");
>                ds.setAttribute("querytype", "POST");
>                ds.setAttribute("type", "http");
>                ds.setAttribute("request", "false");
>                ds.setAttribute("src", "test/nimportequoi");
>
>                //var param = new LzParam();
>                //var xml = ds.getPointer().serialize();
>                //Debug.write(xml);
>                //param.addValue("xml", xml, true);
>                //ds.setQueryString(param);
>                ds.doRequest();
>            </handler>
>
>
> As you can see I try different thing to pass the XML.
> I have to explicitly add xml string as a param if I want to catch it 
> on the Servlet.
> In other words, with that commented version, no XML on the servlet !
> Why ?
>
>
> In other part of my program I got on the servlet the following error :
> 2007-10-19 12:21:06.076::WARN:  /petshop/: 
> java.net.MalformedURLException: no protocol: <localdata/>
>
> or depending on some line commented or not, 2
> 2007-10-19 12:21:06.076::WARN:  /petshop/: 
> java.net.MalformedURLException: no protocol: <here all the dataset XML>
>
> So I got the XML but with that error everytime.
>
>
> Any clues ? 


Henry Minsky wrote:
> Definitely, I know of at least one other person who reported
> encountering this.  cross-posting this to laszlo-user
>
>
>
>
>
> On 10/19/07, David Russell <david.russell at mddm.us> wrote:
>   
>> Ok, good to know. Something along these lines would be good for the docs
>> at some point and perhaps a note in the porting guidelines wouldn't hurt
>> for people coming across from 3.3.x.
>>
>> David
>>
>> P T Withington wrote:
>>     
>>> [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-user mailing list