Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

pagination of results

Avatar

Former Community Member

Hi

I have a webservice which can provide results in different pages(means if I have results 100 for each page i can get 20 results from server side)

my question is how do i show this on Adobe form. I want to show on form with first 20 results and prev, next button when clicked on next button the form should send request to webservice with page number so that server can return me next 20 results,

Can somebody give me some example code pelase?

Thanks

Andy

8 Replies

Avatar

Former Community Member

Are you returning back an XML structure that has the 100 occurances of data in it?

Paul

Avatar

Former Community Member

No I don't return 100 results from form

The scenario is like this I ahve web service which gives results of 100 products

Whe i cal this service from Form instead of showing all the 100 in drop downlist I want to show them 20 each time and user can select one of them.

If he doesn't find his product in first 20 then he click on next button and the Form makes a call to webservice by passing the page number(for eg: next is 2)then he can get the next 20 results in dropdown box.

Hope you got my point.

Thanks

Avatar

Former Community Member

But what are you returning a single string that has the 20 names separated by a comma, or an XML file that has the 20 names in it, or 20 unique parameters that have 20 unique names, something else?

Paul

Avatar

Former Community Member

sorry I couldn't understand what I'm returning means.

what I'm expecting is every time you click on next or previous button , we have to somehow maintian which page(i.e which 20 results )

we are in now.

for eg: we are seeing first 20 results then it's page 1

if i don't find the product I want in this 20 list then I press next button. some how this next button should pass numeric  "2" to the webservice

so that from server i can return next 20 results to show in dropdown box

Finally user selects one product ,whatever is selcted will be sent thru xml for further difference process later.

am i missing something that you expected..?

Thanks for response

Avatar

Former Community Member

Ok so you are returning the 20 results in an XML string (that is what I was trying to determine). So you would set up your webservice to have a single input (int) and a single output (string that holds the XML that has the 20 names in it). You will need a hidden field on the form to hold the page number for th einput (initialized to 0) then a second field to hold the output (multiline text field) You woudl bind the input and output of the web service to these fields. Once you ensure that they are being populated you can make them invisible so the user does not see them. Now that the fields are populating you cannot bind the xml that is returned to the DDList directly as at the time of binding there is no knowledge of its structue. So we will have to load that XML into the Forms DataDom and put the values of the Product into the DDList oursleves.

I have a sample that shows this but I want to make sure that you understand what I talkinga bout before giving it to you as you will not have the Web service to try it with (only the code to manipulate it).

Are you OK with this? It will require some sophosticated javascript in the form. Do you know how to code?

Paul

Avatar

Former Community Member

Hi Paul

The process You said is  right, (actually I return an array of string from webservice. )

I'm just ok with javascript If you can provide me a simple example code(Form with javscript and  call to Web service) I can develope from there to my needs.

Thanks

Avatar

Former Community Member

I do not believe you will be able to pass an array back. Designer only supports simple types. You can pass back a delimited string or xml without issue. In my sample I use XML. You will not be able to access the WS but have a look at the code on the button.

Paul

Avatar

Former Community Member

I do not think you will be able to pass back an array. Designer only supports simple types. You could send back XML or a delimited string. My example uses XML. Note that you will not be able to run the WS but you will be able to view the code and technique that I use.

Paul