Chapter 10. Web Part Connections

WHAT YOU WILL LEARN IN THIS CHAPTER

  • The function of web parts and web part pages

  • How to add web parts to pages and configure them

  • How to use personalized web part configurations

  • How to export web parts and reuse them in other sites

  • Creating composite user interfaces by connecting web parts together

TYPES OF WEB PARTS

Web parts are one of the primary means by which content is displayed in SharePoint. A web part may display static content, a view of a list or library, the interface for a business application, or virtually anything else. This chapter explains which web parts are available in SharePoint, how to arrange them on your pages, and how to connect them together to create rich, composite user interfaces.

Web Part Gallery

The Web Part Gallery is a special, hidden document library that contains the list of allowable web parts for the site collection. In Figure 10-1, you can see the Web Part Gallery contents as they appear in the browser. To display the Web Part Gallery in the browser, choose Site Actions

Web Part Gallery
Figure 10-1

Figure 10.1. Figure 10-1

The available web parts are different depending on the edition of SharePoint and the SharePoint features that have been activated. You can also export web parts from your SharePoint sites and upload them into the Web Part Gallery. That technique will be covered later in the chapter.

You can also add additional web parts by choosing the Documents tab from the ribbon and clicking New Document. SharePoint then checks its web.config file to see which web parts have been authorized to run in the web application and displays the dialog shown in Figure 10-2. To add one or more of the web parts to the Web Part Gallery, select the appropriate checkboxes and click the Populate Gallery button.

Some of the key web parts are:

  • List View Web Part—One of the most common SharePoint web parts, it is almost never shown by this name. That's because when a new list or library is created, a List View Web Part with the same name is created to go with it. Most standard list types include a hidden summary view that the automatic web part uses by default. You can edit the properties of the current view, or you can replace it with any existing view of the list or library. More about this web part was covered in Chapter 8, "XSLT Data Views and Forms."

  • Image Web Part—Enables you to display a picture on a page.

  • Page Viewer Web Part—Enables you to add content from another location to a page. This content can be another web page (or web application), a file share, or even an individual document and is typically displayed in an IFRAME on the current page.

    Figure 10-2

    Figure 10.2. Figure 10-2

    Note

    If the content cannot be rendered in an IFRAME in the user's browser, a popup window may be opened automatically to display it.

  • Form Web Part—Enables you to add HTML form field elements and other content to a page.

  • Content Editor Web Part—Enables you to insert virtually any valid HTML into a page. Although it is often used for static rich text, this web part also allows client-side scripts.

  • XML Web Part—Enables you to display and style XML data. Both the XML data and the XSL styling can be statically entered in the web part, or read from an external source. This allows for flexible presentation of many kinds of information.

  • Data View/Form Web Part—Not available for insertion directly from the web interface. It can be added only through SharePoint Designer and is one of the most powerful tools in your arsenal. Several chapters later in the book are dedicated to showing you how to use the amazing Data View Web Part. More about this web part was covered in Chapter 8, "XSLT Data Views and Forms."

Configuring and Arranging Web Parts

To add a web part to a page, you must first create or open a web part page in SharePoint Designer. To see the list of pages in a site, click Site Pages in the Navigation bar on the left. The screen shown in Figure 10-3 appears.

Figure 10-3

Figure 10.3. Figure 10-3

Site Pages is actually a document library that is automatically added when the site is first created. You can also create pages in document libraries and in the folders of the site directly. To create pages directly in the site's folders, click All Files in the Navigation bar on the left.

Note

The advantage of storing your pages in document libraries is that they are treated like any other document in SharePoint. That means you can use versions, content approval, custom permissions, and workflows to manage them. This functionality is the basis of all content management websites.

To create a web part page, click the Web Part Page button in the ribbon. The layout choices shown in Figure 10-4 appear. Hover over any of the choices to display a tooltip describing the arrangement of the web part zones.

Figure 10-4

Figure 10.4. Figure 10-4

After you choose the best layout option, SharePoint Designer adds a web part page with that layout to your library. The page will first be named Untitled1.aspx, so be sure to rename it before editing it. To edit the page, choose the file and click the Edit Page button in the ribbon. The two modes for editing pages are normal and advanced. Choose normal editing when you simply want to manage the web parts on a page. Choose advanced editing when you want to alter the layout of the page drastically. You need to choose advanced editing mode when you want to add or remove the web part zones on the page.

Warning

Editing pages in advanced mode causes the pages to become customized, which negatively impacts performance. Avoid using that option if the site will have a high volume of web traffic. The reason performance is affected is that your page will originally be read from the web server's file system, and after customization, it is detached from the site definition and stored in the content database. From that point forward, the page is read from the content database, which is much slower than reading it from the file system.

Figure 10-5

Figure 10.5. Figure 10-5

Figure 10-5 shows the page in normal edit mode. Notice the gray areas of the page. These gray areas are web part zones. Web part zones are the only places where you can position web parts. To add a web part to a zone, position the cursor inside the destination zone, and from the ribbon, choose the Insert tab and select Web Part. SharePoint Designer displays a list of web parts that you can choose. If you have many web parts in your site's Web Part Gallery, you can choose More Web Parts at the bottom of the list to display the dialog in Figure 10-6.

You can also insert web parts to display and manipulate data in lists and libraries by clicking one of the buttons in the Insert tab

Figure 10-5
Figure 10-6

Figure 10.6. Figure 10-6

After you add a web part to the zone, a new tab named Format appears in the ribbon. The Format tab allows you to change the appearance and custom properties of the web part. You can see the Format tab in Figure 10-7. The web part in the figure is the Page Viewer Web Part, which you can use to display a web page from another website.

Figure 10-7

Figure 10.7. Figure 10-7

The following table explains the different settings you can change via the Format tab in the ribbon:

NAME

DESCRIPTION

Web Part Title

This is the text displayed at the top of the web part.

Chrome Type

A web part's chrome is the combination of its surrounding border and title bar. This setting allows you to change which part, if any, of the chrome is displayed.

Chrome State

This option controls whether the web part is expanded or collapsed.

Width/Height

Controls the size of the web part. If you leave it blank, the web part will be sized automatically.

Minimize

The web part can be minimized by the user.

Close

The web part can be closed by the user.

Hide

The web part can be made invisible by the user. This means that the web part is invisible unless the page is being edited.

Zone Change

The web part can be moved between web part zones by the user.

Connections

The user can add or remove web part connections.

Edit in Personal View

The user can edit the web part's properties if he edits the page in personal mode. This is covered later in the chapter.

Clicking the Properties button in the ribbon displays a dialog similar to the one shown in Figure 10-8. This dialog allows you to edit the properties that are specific to that type of web part. You can see the different options for the URL to display and the type of link that the URL represents.

Figure 10-8

Figure 10.8. Figure 10-8

The Save Web Part section in the ribbon has two options for exporting the configuration of the web part's properties. You can choose to save the configuration to the Web Part Gallery or to a file. If you export to a file, you can upload it to any other site's Web Part Gallery, provided that the destination site has that web part installed and has been configured to allow it to be used.

Note

If a page is giving you a web part error or someone has accidently closed a web part, you can use Web Part Page Maintenance to remove the offending web part or restore the closed web part. To use Web Part Page Maintenance, navigate your browser to your ShaerPoint site and choose Page tab

Add a Web Part to a Web Part Page Using SharePoint Designer

Personalization

Personalization is a functionality in SharePoint that allows users to customize the configuration of web parts for their own use. Normally, users will see the shared view of a page. When a page is in shared view, any modifications are seen by everyone. To modify the shared view of a page, the user must have Design permission for the site.

When a page is in personal view, users can modify the page, but those modifications are only seen by the individual user. SharePoint stores personalized web part configurations separately for each user. To place a web part page into personal view, choose Personalize this Page from the personal menu as shown in Figure 10-9. To revert to shared view, choose Show Shared View from the same menu. You can also remove your personalizations by choosing Reset Page Content.

One reason you may want to use the personal view is to accommodate web part configurations that would only have value for yourself. Examples include web parts that would display your own stock portfolio or a rollup of blogs that are of interest to you.

Figure 10-9

Figure 10.9. Figure 10-9

Exporting Web Part Configurations

As previously mentioned, you can export the configuration of your web parts. This feature is very useful when you need to add the same web part to multiple pages with the same configuration. To export a web part, open a web part page in SharePoint Designer. Then, select a web part and from the Format tab, click the To Site Gallery button. As shown in the dialog in Figure 10-10, you can enter a name and description for the web part. You should always give a unique name for the web part to avoid confusion for other users. Also, you can click the Set Properties button to modify the new web part's properties before saving it to the Web Part Gallery.

Figure 10-10

Figure 10.10. Figure 10-10

When you click the OK button, the web part is saved to the Web Part Gallery. You can see the exported web part in the menu shown in Figure 10-11. When that web part is added to a page using the browser or SharePoint Designer, it will be automatically configured.

Figure 10-11

Figure 10.11. Figure 10-11

You can also export the web part to a file by choosing the Format tab and clicking the To File button. A File Save dialog appears, allowing you to choose the location and name to save the web part configuration. Configuration files can have either the .webpart or .dwp file extension. If you open the web part file, you will see XML like the file shown in Figure 10-12.

Figure 10-12

Figure 10.12. Figure 10-12

If you are careful, you can modify this file, thereby changing the properties of the web part before you upload it to the Web Part Gallery. If you are planning to edit these files routinely, purchasing XML editing software that will validate your file, rather than using Notepad, would be a good idea.

Note

If you rename the web part file to have an .XML file extension, you can open it in Internet Explorer as a quick check to see if your XML is properly formatted. If the file is valid XML, Internet Explorer will show you the contents of the file. Otherwise, Internet Explorer will display an error and indicate which part of the file is causing the problem.

To upload the web part file, you must navigate your browser to the Web Part Gallery by choosing Site Actions

Figure 10-12
Figure 10-13

Figure 10.13. Figure 10-13

Warning

Be sure to change the filename of the web part file so it is different from the other web parts in the Web Part Gallery or you may overwrite an out-of-the-box web part.

After the web part uploads, the dialog shown in Figure 10-14 appears. In this dialog, you can change the name, title, and description of your web part. You can also add the web part to a group to make it easy to find. If you don't choose a group, the web part will be added to the Custom Web Parts group. After you click the Save button, the web part becomes available for use in the browser and SharePoint Designer.

Figure 10-14

Figure 10.14. Figure 10-14

CREATING A COMPOSITE USER INTERFACE

SharePoint is quickly becoming the "glue" that ties together the disparate back-end systems of any enterprise. With web parts, you can expose those back-end systems through a simple, consistent user interface. Additionally, you can tie these web parts together, thereby tying the back-end systems themselves together, as will be shown in the next section.

Web Part Connections

One of the most powerful features of web parts is their ability to exchange data with each other via web part connections. A web part connection is a link between two web parts on the same page. Web parts can exchange a single value or multiple values. For multiple values, the data is exchanged via a row-like structure or a table-like structure. Exchanging a single value is the most common scenario, though.

To create a web part connection, open a web page in SharePoint Designer and ensure it has two or more web parts. Select the web part that will provide the data to the other web part, and from the ribbon, choose the Format tab and click the Add Connection button. The Web Part Connections Wizard shown in Figure 10-15 launches.

Figure 10-15

Figure 10.15. Figure 10-15

In the first step of the wizard, you can choose whether the web part will provide data or receive data from the other web part. Because the web part chosen in Figure 10-15 is an HTML Form Web Part, which only provides data, only the option to provide form values appears in the drop-down list. When you click the Next button, the dialog in Figure 10-16 appears.

In the second step of the wizard, you can either connect to a web part on this current page or another page in the site. When you choose the second option, you can click the Browse button to find the page you want. After you have selected an option, click the Next button to display the next step in the wizard, shown in Figure 10-17.

In this step, you select the target web part from the first drop-down list and the target property from the second drop-down list. In this example, the target web part and property are the Image Viewer and Image URL. That means that the first web part will provide the Image Viewer web part the value it needs to display its image. Click the Next button to display the step shown in Figure 10-18.

Figure 10-16

Figure 10.16. Figure 10-16

Figure 10-17

Figure 10.17. Figure 10-17

Figure 10-18

Figure 10.18. Figure 10-18

In this step, you must select the property from the source web part that will provide the value for the property on the destination web part. The first web part is the HTML Form Web Part, which allows you to add HTML and JavaScript to a web page without using a tool such as SharePoint Designer. By default, it contains the following HTML:

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
<input type="text" name="T1"/>
<input type="button" value="Go" onclick="javascript:_SFSUBMIT_"/>
</div>

Any input elements in the code snippet will appear in the drop-down list shown in Figure 10-18. In this case, only the input element named T1 appears, which is selected in Figure 10-18. Click Next to display the final confirmation step, and, finally, click Finish to create the web part connection.

Note

In the browser, clicking the OK or Apply button on any arbitrary screen will save your changes. In SharePoint Designer, you will almost always have to click the Save button in the Quick Launch bar at the top of the screen to save your changes.

After you save your page, from the ribbon, click the Home tab and click Preview in Browser to test your web part connection. In Figure 10-19, you can see the web page with the two web parts. If you enter any valid URL for an image in the textbox and click the Go button, the Image Viewer will display the image you entered. In Figure 10-20, you can see the Wrox logo after its location was entered in the textbox.

Figure 10-19

Figure 10.19. Figure 10-19

Figure 10-20

Figure 10.20. Figure 10-20

Example Scenarios

This section of the chapter gives you some ideas for applying what you have learned so far. Two of the more common uses for web parts beyond simple web portals are dashboards for reporting and workspaces that revolve around a single task or job function.

Dashboards

In Figure 10-21, you can see an example of a dashboard. The Item Name and Ship Province Web Parts filter the data used to create the bar and pie charts at the bottom of the screen. In this type of dashboard, the user can manipulate the filters to examine the data from different perspectives. You can create dashboards from any number or type of web parts, but the key is to display charts and graphs rather than tables or lengthy paragraphs. The end result should allow the user to take the "pulse" of the company or department at a glance.

Figure 10-21

Figure 10.21. Figure 10-21

Task-centric Workspaces

Task-centric workspaces are websites that revolve around a particular job function or repetitive task. If you were to create such a site for a user who worked in a call center, the web pages would be populated with web parts that tied the various back-end systems together in one place. Call center users likely need to use a ticketing system for tracking calls, a customer relationship management system for recording ongoing customer interactions, and a searchable knowledge base of information to help the customer. SharePoint gives you the power to bring those systems together so users have one place to go for their information needs. No longer will users have to open several applications on their desktop and constantly switch between them to get their jobs done.

SUMMARY

This chapter explains how you can customize the user interface of SharePoint using web parts. SharePoint provides many web parts out of the box and a massive community exists providing free and for-sale web parts for your use. With web parts, you can quickly create workspaces for knowledge workers and dashboards for managers and executives. In the next chapter, you learn the basics of workflows and how they can extend SharePoint with powerful capabilities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.213.44