BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-22-2007, 03:28 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 7100T
PIN: N/A
Carrier: Cingular
Posts: 23
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ListBox Or Repeater

Please Login to Remove!

I have created one Form Page
and Create a Web service that returns task list in a arraylist for a User.
I like to display this list on form1 and when Item clicked I like to take them to form2 for details.

How Can i use list box or repeater to list this webservice method that return olist. Form1.listbox1.source does not exist. or Should i use repeater.

Anycode would be appricated.
Offline  
Old 10-25-2007, 10:55 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: Rogers
Posts: 140
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok.. bare with me.. this is what you want to do.

When you have added the web reference (pointing to your web service) to your blackberry project you will notice that you can expand it. When you expand it you will see that it lists the objects that you have defined and returned from your web service.

Select the object you want to show in the list. What you want to do is make this object a collection. Whether you want it to be persisted in flash or not is up to you. If you make it a persistent collection it will save to flash.

When you make this a collection you will have to specify a primary key. The reason you do this is that by making it a collection you are basically making it a hash table that needs a unique key. So make sure that the object list that you are returning has a unique field on it.

Now that you have made it a collection, go to your Form editor and we can display this information. If you want to display more than just one field of the object in a list then you will want the Repeater. If you want to display only one field of the object you can use the ListBox.

Lets say you want to show more than one field. So drag a Repeater control onto your form. Then go to the databindings of the Repeater and set the databindings for the Items. What you will notice is that you can only set either a collection or an array of objects to the databindings of the repeater. So in here you will select your object that you just made a collection. Press OK.

Now what happens in a Repeater, is that for every instance of an object found inside the data bindings (in your case the collection) it will repeat the UI controls that you place into the repeater. Similar to an ASP.NET Repeater control.

So drag one or more TextBox controls into your Repeater. Then select the databindings of the TextBox and the editor will open again. You will now see that you have the Repeater itself as a possible data source for your Textbox. Expand the Repeater data source and you will see all the fields of your object. Select whichever field you want to display in the textbox and press OK.

Your Form is now all set to go... next step is calling your webservice. One thing to remember is that all the calls to your webservice are asynchronous.

So add a button to the top of your form and double click on it to be brought down to the JavaScript event for the Click of the button. In here you will invoke your webservice method call to get your User array list back.

The code will look something like

var myService = new mywebReference().myService;
myService.MyMethodNameAsync(Myparam1, Myparam2);

This will invoke the webservice call on the server. So the next step is to refresh your screen when the data comes back. If you mark an object as a collection and then have that object returned as the result of a web service call, it will automatically be put into your collection. So all we need to do is refresh the screen when it comes back.

An easy way to do this is go back to your Form, select it, and go to the RefreshMessages property of the Form. In here you should see the return message from your web service call along the lines of "MyMethodNameCompleted". If you check this off, the Form will be refreshed everytime this completed result returns to the device.

All you should have to do now is run it in the simulator and try it out.

There is a good sample that comes with the tool around this that mimics the Northwinds database and some other samples that you would find useful.

Go to your Start -> Programs -> Research In Motion -> Visual Studio Plugin -> Sample Browser

This browser shows you all the samples that came with the tool...
Offline  
Old 10-26-2007, 03:29 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 7100T
PIN: N/A
Carrier: Cingular
Posts: 23
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mate
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.