Here is what I've done for a single portlet, a stock quote panel.
We have a gadget that displays stock quotes. We have an account with Tickertech for them to provide us with quote information. There are user preferences which allow people to add the gadget to a private page and then select stocks of interest to them as individuals. You also can select which columns to display. This is accomplished through JavaScript. The selected stock symbols are sent along with a token which identifies the request as coming from a valid customer.
The simplest approach was to use a web content control and just paste in the JavaScript. This works but leaves no way for a user to change the stock symbols or other preferences involving Tickertech.
The next step was to create a custom Webpart. We are using the WSPBuilder add-on to Visual Studio. The consulting firm that is helping us with the project reccomended it and I'm very glad they did, reduces the integration cycle to a tolerable level.
In the webpart we have a property that contains the script.
public class MarketSummaryWP : Microsoft.SharePoint.WebPartPages.WebPart
{
string m_scriptBlockPre = "<script language='javascript'> \n"+ // the beginning of the JavaScipt block
In the CreateChildControls() override, I just added it as a literal.
this.Controls.Add(new LiteralControl(this.Script));
Next I changed the script to be private and created another property to hold the stock symbol list. Notice out the Script property does the concatenation inside the getter.
//Script Property
[WebBrowsable(false),
WebDisplayName("Script"),
WebDescription("The JavaScript to insert in the page.")]
public string Script
{
get { return m_scriptBlockPre + m_stockSymbolsList + m_scriptBlockPost; }
//set { ; }
}
//Stock Symbol list Property
[Personalizable(PersonalizationScope.User), WebBrowsable(true),
WebDisplayName("Stock Symbols"),
WebDescription("The stock symbols to retrieve quotes for, seperated by commas.")]
public string StockSymbols
{
get { return m_stockSymbolsList; }
set { m_stockSymbolsList = value; }
}
string m_stockSymbolsList = "GE,CAT,$DJI,AMR,JNJ,";
string m_scriptBlockPost = " *other JavaScript code* </script> \n"+
This gets me a webpart that can be added to any page because it is in the webpart gallery. To add a copy of the webpart built using the static html webpart, you'd need to get the JavaScipt block from an existing instance probably using 'view source', navigate to the target page, add a new instance of the static HTML webpart, and modify it to include the JavaScipt block; each time. This way the users only have to select it from a list of webparts and they can have customized stock quotes preferences.