Building Advanced Web Parts - dFPUG

Download Report

Transcript Building Advanced Web Parts - dFPUG

Advanced Web Part
Development
Thomas Robbins
Microsoft Consulting Service
New England
[email protected]
Agenda

Understand the Digital Dashboard
Framework


Web Parts







Schema
Dashboard Factory processing
Token Replacement
Digital Dashboard Services Component
Personalization
Web Parts Development Kit
Development



Dashboard Architecture
Microsoft Office XP Developer
Debugging
Wrapping .NET Web Services
SPS Dashboard Architecture
Office/Outlook,
Internet Explorer
Services for Web
Parts
Assembly of
Dashboard content
and format
API for accessing
Dashboard store
Storage of
Dashboard and part
metadata
Dashboard Client
Web Part Web Part Web Part
DD Services Component
Content
Services
LOB
Dashboard Server
Dashboard Factory
BI
Store Interface
KM
WSS
What is a Web Part Really?

A Web Part is:



A Web Part can:




Embedded web application
Reusable web component
Collect data
Display Data
Contain an independent application (IM)
It conforms to schema defined by the
Web Part SDK
Basic Web Part Properties






Title – Short name for the part
Description – Longer description of the part
IsIncluded – Whether part is included on the
Dashboard page
MasterPartLink – URL to “template” version
of part
LastModified – Used to determine whether
part needs to be updated
PartStorage - Part customization information
Web Part Content Properties






ContentType – XML, HTML, VBScript or
JScript
ContentLink – URL from which to get content
(HTML, XML or script)
Content – Embedded content or fallback
content when ContentLink fails
RequiresIsolation – Specifies the part to be
isolated from other parts (via IFrame)
XSL / XSLLink – Embedded XSL and URL to
get XSL used to transform content
Resource (new) – associate resources (.gifs,
XSL’s, etc.) with a .dwp
Behavior Properties




CustomizationLink – URL for
customizing part content. Used when
user clicks customize link in title bar
DetailLink – URL to a full-page, detailed
UI. Used when user clicks part title
AllowRemove – Enables the user to
remove the part from the Dashboard
AllowMinimize – Enables the user to
minimize the part
Factory Processing Flow
Resolve
MasterPartLink
Web
Part
Req.
Isolation
Yes
Render IFrame
w/ContentLink
No
Content
Link?
Yes
Get Content
From ContentLink
Success
No
Failure
Get Embedded
Content
Content
Next
Token Replacement
Token
_WPQ_
_WPR_
_WPID_
_DashboardID_
_LogonUser_
Replacement
Qualifier for this Web Part instance
with respect to other Web Parts in
the same dashboard.
Location of resource files
directory.
Unique ID of this Web Part. Format
may vary between data stores.
Unique ID of this dashboard.
Format may vary between data
stores.
Value retrieved from ASP Server
Variable LOGON_USER.
Factory API’s

Server Variables




Factory inspection
Standard IIS Server variables
Object Creation
Cookies and Queries
Function getContent(node)
Dim strContent
strContent = "Factory doesn't exist."
If (Not (IsEmpty(Factory))) Then
If (Not(Factory Is Nothing)) Then
strContent = "<b>Factory exists</b>"
' Test Variables
strContent = strContent &
"<br><b>#Variables: </b>" &
Factory.Variables.Count
strContent = strContent &
"<br><b>LOGON_USER: </b>" &
Factory.Variables.Item("LOGON_USER")
Factory.Variables.Item(“LOGON_USER”)
strContent = strContent &
"<br><b>SERVER_SOFTWARE: </b>" &
Factory.Variables.Item(
"SERVER_SOFTWARE")
Factory.Variables.Item(“SERVER_SOFTWARE”)
strContent = strContent &
"<br><b>HTTP_USER_AGENT: </b>" &
Factory.Variables.Item(“HTTP_USER_AGENT”)
Factory.Variables.Item(
"HTTP_USER_AGENT")
End If
End If
getContent = strContent
End Function
Digital Dashboard Services
Component (DDSC)

Easy-to-use services for Web Parts





Discovery
Notification
Session State
 Part State

Method definitions are inserted into page by
Dashboard factory
Web Parts can be combined into an
integrated application
Allows cooperative Web Parts to be
developed and deployed independently
Discovery Service





Allows Web Parts to discover other
parts that reside on a Dashboard
Current Dashboard available via the
Dashboard() method on the DDSC
Collection of parts on the current
Dashboard available via the Parts()
method on the Dashboard object
Part object provides access to DOM
and part properties
Dashboard factory automatically
registers parts on a Dashboard page
Notification Service




Provides standard multi-cast event
mechanism for Web Parts
Hides the complexity of the underlying
event mechanisms of browser or OS
System and custom events are
handled in exactly the same way
OnLoad - urn:schemas-microsoftcom:dhtml
Web Part Notification
Web Part
Web Part
DDSC
urn:company-com:caronSelect
<Car>
...
</Car>
urn:company-com:caronSelect
Session State


Provides mechanism for Web Parts to
interchange context information within a
Dashboard session
Setting session state


Retrieving session state


PutSessionState ( NamespaceURN, Name,
Value)
Value = GetSessionState (NamespaceURN,
Name)
Clearing session state

ClearSessionState (NamespaceURN, Name)
Personalized Web Parts




Recommended way to personalize a SPS
workspace
Show/hide based on user/group/role
Script Web Parts have access to the part
schema. This allows developers to change
properties on the fly that are NOT persisted to
the store
Hide a Part Sample


Node.SelectSingleNode(“//IsIncluded”).text =0
Consider creating business functions in
dashboardextensions.vbs to determine
visibility
Microsoft Office XP Developer


The first integrated development tool
for building dashboards
Easily create sub-dashboards and web
parts


Shell is built on top of Visual Studio
.Net


Familiar interface for setting properties
HTML and XML IntelliSense®
No built-in debugging
Working with Dashboards



Create a new Dashboard Project
Location:
http://<server>/<workspace>
Name: Portal
Digital Dashboard
Resource Kit 3.0


Unsupported toolkit for building Web Parts
and custom digital dashboards
Three CD set

SQL Server Sample dashboard and mobile
dashboard preview




Mobile preview: PocketPC (offline), WAP
MOD XP patch for SQL dashboards (preview)
SharePoint Portal Server 120 day eval
Web Part Development Kit



Papers, tools and sample Web Parts
Snapshot of the online WP Gallery
Web Part schema matches SPS
Server Side Debug

Set up Server to enable server side debug

Bring up IIS Manager






Locate the “Portal” vroot for the workspace
Select “properties”
Change Application Protection to “Low”
“Configuration” button
“App Debugging” tab,


Program – Admin tools – Internet Services Manager
Check “Enable ASP server side script debugging”
Recycle W3svc
Server Side Debug (cont’)

Attach the script debugger


You need to open the portal page at least once after
W3svc is started
Launch Script debugger OR
 Windows


script debugger is “free” in Win2K
Programs – Accessories – Microsoft Script debugger
Microsoft Visual Interdev 6.0
 Attach

to inetinfo.exe process
Debug - Process
Server Side Debug (cont’)

VBScript Web Part debugging
 From
the running documents, find the
dashboard.asp
 Search for “Execute(”, and set break points
on “Execute(init)” and
“Execute(GetContent)”
 Why ? Because that’s how dashboard
factory process the Web Part.
 From your browser, navigate to (or refresh)
the dashboard with this Web Part. You
should see the break point hit.
Server Side Debug (cont’)

XML/XSL involved
 Use
XML/XSL tools to validate
 XSL Debugger in XML SDK or commercial
program (ex. Visual XSLT)
 Make change on XSL. To apply the changes,
you may have to flush cache
 in
the management dashboard
 Or recycle w3svc
Debugging Tips and Tricks





Between part saves flush the cache and
open a new browser window
Open a second browser windows to flush
the cache between changes
If you’ll be doing significant development
create a temporary dashboard with just that
part
Within dashboard.asp the current webpart is
called xmlwebpart
If an error occurs in the XSL transformation
find the function ApplyPartXSL. Set a break
point at the end. The Err object will contain
the error from the transformation
Wrapping .NET Web Services

Web Parts support consuming Web
Services




Visual Studio.NET



Call a .NET Web Service
Return an XML data stream
Transform to HTML
Hello World Example
Single Web method called HelloWorld
No CLR support yet
Configure Web Part
http://<server>/webservi
ce2/service.asmx/Hello
Word?
Final Web Part
Summary




Web Parts as an application
development platform
Understanding the framework
provided by the Digital Dashboard on
top of SPS
Development strategy
Resources to move forward
Questions ???
For copies of slides:
[email protected]
http://www.microsoft.com/usa/newengland