Book Image

Microsoft SharePoint 2010 Business Application Blueprints

Book Image

Microsoft SharePoint 2010 Business Application Blueprints

Overview of this book

SharePoint is an incredibly powerful platform that can support a wide variety of business scenarios. In many cases it needs to be configured or extended in order to deliver fully featured business solutions. While some books merely talk about the capabilities of SharePoint in general and leave you to figure out how they apply to your situation, this book takes a different approach. Each chapter provides easy-to-understand, step-by-step instructions along with screenshots to help build exciting SharePoint business solutions that extend the platform. By the end of this book the reader will be a SharePoint developer to be reckoned with. This book will dive into a diverse set of real-world scenarios to deliver sample business solutions that can serve as the foundation for your own solutions. This book draws from the author's extensive experience with SharePoint to leverage the platforms underlying services to provide solutions that can support Social Collaboration, Content and Document Management, as well as project collaboration. Each chapter represents a new business solution that builds on the overall platform to deliver more complex solutions and more advanced techniques. By the end of the book the reader will understand how to leverage the SharePoint platform to build their own business solutions.
Table of Contents (15 chapters)
Microsoft SharePoint 2010 Business Application Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Building a Stock Ticker Web Part


For publicly traded companies it is also desirable to display the current stock quote information. Like the Weather Web Part previously configured, there are many publicly available services that can provide this information. For this example, we will query a REST based service provided by Yahoo having the following address:

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol in ("MSFT")&env=store://datatables.org/alltableswithkeys

Approach

The stock quote information can be shown in a number of different ways. In cases where the information needs to be on every page, it should be added to a container on the Master Page with the s4-notdlg style reference previously included in the Building an Appropriate Use and Incident dialog section. For this example though, we will include it as an XML Web Part configured in a similar way to the Weather Web Part previously reviewed.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template name="main">
<xsl:variable name="symbol" select="results/quote/Symbol"/>
<xsl:variable name="price"
select="results/quote/LastTradePriceOnly"/>
<xsl:variable name="change"
select="results/quote/Change_PercentChange"/>
<div id="stockInfo" style="font-size:10pt">
<xsl:value-of select="$symbol" />
<xsl:text> $</xsl:text>
<xsl:value-of select="$price" />
<xsl:text> </xsl:text>
<xsl:value-of select="$change" />
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="contains($change,'+')" >
<img
src="http://intranet/Style%20Library/Images/stock_up.png"
border="0" alt="Trending Up"></img>
</xsl:when>
<xsl:otherwise>
<img
src="http://intranet/Style%20Library/Images/stock_down.png"
border="0" alt="Trending Down"></img>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
<xsl:template match="/*">
<xsl:call-template name="main"/>
</xsl:template>
</xsl:stylesheet>

Stock Quote Web Part displayed

A rendered version of the current Stock Ticker Web Part can be displayed in the following screenshot: