PDA

View Full Version : Problem with retrieve data


mohan
07-30-2003, 03:49 AM
Hi,

I want to pass the value selected in the combobox to the next page, and in the next page i have to retreive this passed value and send it to the jsp page as querystring.This jsp generates the xml based on the querystring value and the data from xml is loaded back to the page. I m just sending the part of the code of the first page. I know i am doing the mistake here pls help me to set the value in first page and retreive it in the second page.

<custompulldown name="seeking" itempath="sex:/gender/text()" >
<attribute name="btfParent" init="this.parent" />
</custompulldown>
<view name="Go" x="205" y="155" resource="images/mi_search_go[1].gif" clickable="true" onclick="postpage" >
<method name="postpage" event="onclick">
seeking.retrieveData();
Go.setQueryString( { sek : seeking } );
Go.doRequest();
debug.write(seeking.retrieveData());
LzBrowser.loadURL('nextpage.lzx?'+seeking.retrieve Data(), '_self');
</method>
</view>

antun
07-30-2003, 07:18 AM
Whoa there! Before we even begin; why are you building a multi-page lzx app? Although you can do this, It's not considered best practices at all.

For a start, a page refresh is going to ruin the user experience by forgetting the state of the first, so the back button will be useless.

Second, it will be slow.

You can use states or turn visibility of things on and off to get a desired effect, but definitely avoid the page-page metaphor.

-Antun

mohan
07-30-2003, 08:23 AM
Hi Antun,

Loosing the state is not a problem, but my requirement is to pass the selected values from the page1 to page2 in a querystring.

Pls let me know the way to pass the values and to access the same in the second page.

antun
07-30-2003, 09:54 AM
You would use the getInitArg() method of the LzBrowser service:

http://www.laszlosystems.com/developers/learn/documentation/lzxref/lzbrowser.php#meth-getInitArg

Something like:


LzBrowser.getInitArg( 'foo' );


... would get you a GET variable named "foo".

However I really must stress that this is not a good idea. Using a page-page metaphor is not what Laszlo was designed for, on the contrary it was designed to fix the problems with the page-page metaphor in web applications.

Can you tell me why you're trying to do this, and maybe I can help you design around it?

-Antun

mohan
07-30-2003, 07:18 PM
Hi Antun,

actaully i have got 4 selection fields in the first page where the user selects the sex,age and enters a zip code. based on these entries i have to query from the database and display the results in the second page.

antun
07-30-2003, 10:45 PM
There's no reason you can't do that in a single page. In the Weather application:

http://www.laszlosystems.com/demos/weather/

... you fill out a single field, which queries a back-end, that populates the next part of the app. It's all one single LZX app.

You would have your form fields. Here's a very rough example:


<view name="myFormFields">
<inputtext name="field1" />
<inputtext name="field2" />
<inputtext name="field3" />
<inputtext name="field4" />
</view>


... then when you collect the values (probably in a method that's called somewhere on a mouseclick), and set them to the querystring of your dataset (here the dataset is named "myDataset").


<button>
<method event="onclick">
myFormFields.setVisible( false );
myDataset.setQueryString( { field1: field1.getText(),
field2: field2.getText(),
field3: field3.getText(),
field3: field3.getText() } );
myDataset.doRequest();
</method>
</button>


To make this form part of the application go away, I used the setVisible() method on an enclosing view. You could use some animation to transition instead.

Finally you'll want to show the next stage of the app. You might declare that like so:


<view name="queryResults" visible="false">
<view datapath="myDataset:/......">
...
</view>
</view>


... so that visibility is turned off when it's first instantiated, and then you could turn it on with a method call as follows:


queryResults.setVisible( true );


Do you see what I mean?

-Antun