Well, as I suspected, this is not such a clean solution.
What I found is that because everything inside the state is
"destroyed" when the state is removed and recreated again when the
state is applied, the grid no longer remembers the last column being
sorted, so it starts from scratch again :(
Any help now would be appreciated :)
Thanks,
Daniel
On May 25, 2006, at 3:13 PM, Daniel Salama wrote:
> Ok. I was able to fix the problem. Although I don't know if my
> solution is correct and elegant.
>
> What I ended up doing was:
>
> 1) I created a datapointer on the window pointing to just "response"
> 2) I enclosed the messages view and the grid in a state, with
> apply=false
> 3) The "submit" button removes the state before doRequest to the
> dataset
> 4) The datapointer has an ondata event which applies the state when
> data comes in
>
> Now the application works. However, I don't feel comfortable with
> this solution. I guess the reason why it's working is because the
> constant apply/remove of the state is destroying/creating the view
> and the grid objects (I'm not using pooling=true). So that would be
> my only explanation why it works and not necessarily because the
> state is applied or not.
>
> Any suggestions?
>
> Thanks,
> Daniel
>
> On May 25, 2006, at 1:40 AM, Daniel Salama wrote:
>
>> This may be a newbie question, but I'm stuck and I need help.
>>
>> I have a window with a button that triggers a dataset's doRequest
>> method to fetch data from a remote server.
>>
>> The returned data may come in two different formats:
>>
>> <results success="true">
>> <countries>
>> <country id="1" code="US" />
>> </countries>
>> </results>
>>
>> or
>>
>> <results success="false">
>> <errors>
>> <message code="404">Not Found</message>
>> </errors>
>> </results>
>>
>> So, in my window I have something like:
>>
>> <view name="messages"
>> datapath="[EMAIL PROTECTED] = 'false']/errors/"
>> width="${parent.width}" height="${parent.height}">
>> <text datapath="message/text()" resize="true" multiline="true" />
>> </view>
>>
>> <grid name="countryGrid" sizetoheader="false"
>> datapath="[EMAIL PROTECTED] = 'true']/countries/"
>> width="${parent.width}" height="${parent.height}">
>>
>> <gridtext width="25" sortable="false" resizable="false"
>> editable="false" datapath="position()">
>> #
>> </gridtext>
>> <gridtext width="40" editable="false" datapath="@code">
>> Code
>> </gridtext>
>> </grid>
>>
>> Basically, the idea is that depending on the parameters sent to
>> the server, either the error message(s) will be displayed or the
>> grid will be displayed. However, here is what's happening:
>>
>> When I initially submit a request that returns valid data, the
>> grid displays fine. I can even re-submit another request with
>> different parameters to return data and the currently displayed
>> grid is updated accordingly with the new returned data. However,
>> if I submit invalid parameters that return the "error" messages,
>> the grid remains displayed, the messages view is not displayed,
>> and the application is stuck. I can't even type in the debugger or
>> do anything in the application.
>>
>> Now, here is another twist. If I initially submit a request that
>> will return the error response, the messages view is displayed as
>> expected. While the messages view is displayed and I submit a
>> request that will return good data, the messages view is not shown
>> and the grid is shown with the proper data. At this moment, I can
>> re-submit the request to return more valid data and the displayed
>> grid is updated accordingly. However, if I submit a request that
>> will return the error response, the application freezes again,
>> where I can't click on anything or type anything.
>>
>> Did I miss something?
>>
>> Just to be complete, on that same window I have a simple form that
>> prompts the user for some parameters to include in the query
>> string. The "submit" button simply checks if the user typed
>> anything and updates the dataset's URL accordingly and then issues
>> the doRequest method. Watching the back end server, I can see that
>> the requests are being sent correctly and it's returning the
>> proper XML documents.
>>
>> Do I have to play with setVisible somewhere or do I need to reset
>> the datapath's of the components in any way?
>>
>> Help please!
>>
>> Thanks,
>> Daniel
>
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user