| Getting Started with Flex 2 > Lessons > Use Web Services > Create a dynamic link | |||
The web service doesn't provide the full text of the posts, but you still want users to be able to read the posts if they're interested. While the web service doesn't provide the information, it does provide the URLs to individual posts. According to the API documentation for the getMostPopularPosts method (see Review the API documentation), the information is contained in a field called postLink.
You decide to create a dynamic link that opens a browser and displays the full content of the post selected in the DataGrid control.
click property in the <mx:LinkButton> tag (in bold):
<mx:LinkButton x="30" y="250" label="Select an item and click here for full post"
click="navigateToURL(new URLRequest(dgTopPosts.selectedItem.postLink));"/>
The value of the link field of the selected item in the DataGrid control, dgTopPosts.selectedItem.postLink, is specified in the argument to the navigateToURL() method, which is called when the user clicks the LinkButton control. The navigateToURL() method loads a document from the specified URL in a new browser window.
|
NOTE |
|
The navigateToURL() method takes a URLRequest object as an argument, which in turn takes a URL string as an argument. |
A browser opens and runs the application. Click an item in the DataGrid control and then click the LinkButton control. A new browser window should open and display the blog page with the full post.
In this lesson, you used a WebService component to call and pass method parameters to a SOAP-based web service. You then bound the data returned by the web service to a DataGrid and a LinkButton control. To learn more, see the following topics in Flex 2 Developer's Guide:
Flex 2.01