The pageComponentFactory object in Visual C#

Creating QR Code in Visual C# The pageComponentFactory object

Listing 10.13 The pageComponentFactory object
Print Denso QR Bar Code In C#
Using Barcode printer for .NET Control to generate, create QR-Code image in .NET applications.
www.OnBarcode.com
Decoding Denso QR Bar Code In C#.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
function pageComponentFactory(webPartPageComponentId, componentClass, jsFile, jsFilePath) {
1D Maker In Visual C#.NET
Using Barcode creator for VS .NET Control to generate, create Linear Barcode image in .NET framework applications.
www.OnBarcode.com
Generating QR Code JIS X 0510 In C#.NET
Using Barcode generation for VS .NET Control to generate, create QR Code JIS X 0510 image in VS .NET applications.
www.OnBarcode.com
Creates pageComponentFactory
Barcode Generation In Visual C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Making Data Matrix ECC200 In C#
Using Barcode printer for Visual Studio .NET Control to generate, create Data Matrix image in VS .NET applications.
www.OnBarcode.com
this.webPartPageComponentId = webPartPageComponentId; this.pageComponent = null; this.jsFile = jsFile; this.jsFilePath = jsFilePath; this.componentClass = componentClass; this.add = function () { if (typeof SP.Ribbon.PageManager.get_instance(). getPageComponentById(webPartPageComponentId) == 'undefined') {
EAN 128 Creator In C#
Using Barcode drawer for .NET Control to generate, create GS1-128 image in VS .NET applications.
www.OnBarcode.com
Generating Identcode In C#
Using Barcode creation for .NET Control to generate, create Identcode image in .NET framework applications.
www.OnBarcode.com
Defines add function
QR-Code Reader In VB.NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Read Denso QR Bar Code In .NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
pageComponent = new RssWebPart.CustomPageComponent( webPartPageComponentId); SP.Ribbon.PageManager.get_instance(). addPageComponent(pageComponent); } }
Encoding UPC A In .NET Framework
Using Barcode printer for Reporting Service Control to generate, create UPCA image in Reporting Service applications.
www.OnBarcode.com
Generating EAN-13 Supplement 5 In None
Using Barcode printer for Microsoft Word Control to generate, create EAN 13 image in Microsoft Word applications.
www.OnBarcode.com
Dynamic interfaces in Web Parts
Encode EAN-13 Supplement 5 In Objective-C
Using Barcode maker for iPhone Control to generate, create EAN13 image in iPhone applications.
www.OnBarcode.com
Print Code39 In Java
Using Barcode printer for Android Control to generate, create USS Code 39 image in Android applications.
www.OnBarcode.com
} Defines register pageComponentFactory.prototype = { function register: function () { SP.SOD.registerSod(this.jsFile, this.jsFilePath); SP.SOD.executeFunc(this.jsFile, this.componentClass, this.add); } }
Barcode Generator In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Decode DataMatrix In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
The pageComponentFactory constructor B takes four arguments. The first is the id of the Web Part component and the second is the class that was registered. The last two parameters are the name and location of the JavaScript file where the page component is registered. The object contains one local method called add C, which instantiates the page component if there isn t already a page component with the specific id created. Then it adds the page component to the SharePoint Ribbon Page Manager. The JavaScripts in SharePoint contain a set of functions called Script On Demand (SOD). These functions allow you to register JavaScript files as they re loaded and notify registered functions to execute when they re loaded. The second method of the page component factory is the register D function. The register function is the first method called; it will register the JavaScript file using the SP.SOD.registerSod function and then connect the page component class and method to it using the SP.SOD.executeFunc function. Once the JavaScript file is loaded by SharePoint, it will execute the function specified in the last parameter, in this case the add function.
Make UCC - 12 In Objective-C
Using Barcode drawer for iPhone Control to generate, create GTIN - 128 image in iPhone applications.
www.OnBarcode.com
Encoding Data Matrix In None
Using Barcode maker for Microsoft Word Control to generate, create Data Matrix ECC200 image in Microsoft Word applications.
www.OnBarcode.com
More information about the Script On Demand functions in SharePoint 2010 can be found in the SharePoint 2010 SDK; http://msdn.microsoft.com/library/ff410742.aspx.
Recognize Quick Response Code In Visual Studio .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Encoding Barcode In .NET
Using Barcode creator for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
To use this page component factory, you add a function to the JavaScript file. This function will be called from the Web Part using the page component id that will be used for the Web Part:
function createRssRibbon(webPartPageComponentId) { return new pageComponentFactory(webPartPageComponentId, 'RssWebPart.CustomPageComponent', 'DynRSSWebPart/rssribbon.js', '/_layouts/DynRSSWebPart/rssribbon.js'); }
This function takes the id of the Web Part page component as parameter and then creates a new pageComponentFactory object specifying the class and the JavaScript. When the register method is called on the returned pageComponentFactory object, it will wait for the RSSRibbon.js file to load; the method then invokes the add method, as in listing 10.13. You have one more thing to add to the custom JavaScript file (RSSRibbon.js): the code that informs the SOD Manager that the file is loaded. This has to be added to the end of the JavaScript file:
SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs( "DynRSSWebPart/rssribbon.js");
Enabling a Web Part to use the Ribbon
CONNECTING THE WEB PART TO THE PAGE COMPONENT
Now that you have all the necessary JavaScript code for the contextual Web Part, it s time to modify the Web Part so it can connect to the Ribbon and page component. The first thing that you need to do is make the Web Part class implement the IWebPartPageComponentProvider interface. This interface contains one property that returns information about the current Web Part Ribbon status. When the Web Part Manager adds the Web Parts to the page, it queries for this interface; if it s found on a Web Part, the Manager will retrieve the contextual and page component information from the Web Part and register the associated Ribbon tabs. Modify the class definition of the Web Part so that it looks like this:
public class DynamicRSSWebPart : WebPart, IWebPartPageComponentProvider
Then right-click on the newly added interface and select Implement Interface > Implement Interface. This adds the property of the IWebPartPageComponentProvider interface to the Web Part. Change the implementation so that it looks like listing 10.14.
Listing 10.14 Implementing the IWebPartPageComponentProvider interface
public WebPartContextualInfo WebPartContextualInfo { get { WebPartContextualInfo contextInfo = new WebPartContextualInfo(); contextInfo.ContextualGroups.Add(new WebPartRibbonContextualGroup() {
Sets id of
Contextual Group Id = "WebPartsInAction.ContextualTabGroup", VisibilityContext = "WebPartsInAction.CustomVisibilityContext", Command = "RssWebPart.ContextualGroupCommand"
Sets id contextInfo.Tabs.Add(new WebPartRibbonTab() { of Tab Id = "WebPartsInAction.RssContextualTab", VisibilityContext = "WebPartsInAction.CustomVisibilityContext" });
contextInfo.PageComponentId = SPRibbon. GetWebPartPageComponentId(this); return contextInfo; } }
Copyright © OnBarcode.com . All rights reserved.