The Business Requirements
I wish to easily set up a Web site that serves as an RSS Reader. There are a number of such Web-based RSS Readers available such as Bloglines, NewsGator, etc.
Thus the business requirements for such an RSS Reader include the following:
Breaking Down the Problem: the Functional Requirements
- The RSS Reader will allow me to maintain my RSS feeds (the OPML).
- The RSS Reader will allow me to select one of the RSS feeds out of my OPML.
- When the user selects an RSS feed, I should then be able to view that RSS feed rendered on the page.
Similar to my last article, this article does not feign to be a course in the software development life cycle. But now that I have business requirements specified, it makes sense to follow them with functional requirements that my system will need to meet, in order to satisfy the business requirements stated above. Thus here are the functional requirements of my system.
Designing and Implementing the System
- The system will contain a Web Part that allows users to select a given RSS feed out of their OPML. Users can select only one feed at a time. This will satisfy business requirement #2.
- The Web Part written in functional requirement #1 will also come with a custom editor, which will allow the end user to maintain their OPML feeds. This will satisfy business requirement #1.
- Finally, the Web Part written in functional requirement #1 and the RSSRender WebPart from the previous article will be able to communicate. They will be able to pass between them the RSS feed URL that the end user has selected and the RSSRender WebPart, which will render that RSS feed in its UI. This will satisfy business requirement #3.
It is clear from the functional requirements that I need to write a brand-new Web Part that allows the user to maintain their OPML and provides them with a UI that has radio buttons against the various RSS feeds in the OPML. This Web Part will also have a simple editor that allows the end user to edit their OPML.
I will also need to enhance a Web Part I have already written, which is the RSSRender WebPart, so it can communicate with the OPML WebPart.
Thus, I have two chunks of work, the Winsmarts.OPMLEditor WebPart, and the Winsmarts.RSSRender WebPart.
I'll dig into these one by one in the rest of this article.
Writing the OPML Editor Web Part and Its Editor
The Winsmarts.OPMLEditor WebPart is implemented as a class library. I am going to avoid covering the basics of writing Web Parts and their editors in this article and simply present you with the necessary code excerpts. You can find the entire code in the associated code download on my Web site.
Listing 1 shows the rendering portion of the OPMLEditor WebPart. As you can tell, this Web Part maintains a list of all RSS feed URLs in a private variable of type List<String>. It then provides the user with a simple UI with radio buttons to allow the user to select any one of those URLs. The idea being, when this Web Part is connected to the RSSRender WebPart, that selecting a radio button will cause the RSSRender to display the feed contents.
For users to manage their feeds, I also went ahead and wrote a very simple editor part. You can see this editor part's ApplyChanges and SyncChanges methods in Listing 2. A quick examination of the code tells you that all I am doing here is converting to and from a simple CSV list of RSS feed URLs. In a real-world application you would probably want to create a more sophisticated UI, but for this concept demonstration I am using a simple multi-line text box.
Figure 2 shows the Web Part with some sample data, and you can see the corresponding editor in Figure 3.
|Figure 2: Your first Web Part, which lets you edit an RSS feed list.||
|Figure 3: The rather simple and rudimentary editor for the OPMLEditor.UIWebpart Web Part.||