您的位置:首页 > 其它

Sharepoint习题——Custom Action

2014-09-12 08:55 495 查看
Question16
You plan to add a custom tab to the Ribbon in a SharePoint Web application.
You create a custom Feature that contains an Elements.xml file.
You need to ensure that the custom tab only appears in the document libraries of the Web application.
Which code segment should you add to the Custom Action node of the Elements.xml file?
A. Location="DocumentLibrary"
B. RegistrationId="101"
C. RegistrationType="List"
D. ShowInLists="false"
 

解析:

 本题的题意是要你设置你添加的Tab容器的显示时机。也即它只与Document Libraries关联显示。

先看一段Ribbon的Element.xml样例

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<CustomAction

Id="DemoHelloWorldButton"

RegistrationType="List"

RegistrationId="101"

Location="CommandUI.Ribbon">

<CommandUIExtension>

<CommandUIDefinitions>

<CommandUIDefinition

Location="Ribbon.Documents.New.Controls._children">

<Button

Id="Ribbon.Documents.New.Controls.DemoHelloWorldButton"

Alt="Hello World Ribbon Button"

Sequence="10"

Image32by32="/_layouts/images/PPEOPLE.GIF"

Command="Demo_HelloWorld"

LabelText="Hello World Demo"

TemplateAlias="o2"/>

</CommandUIDefinition>

</CommandUIDefinitions>

<CommandUIHandlers>

<CommandUIHandler

Command="Demo_HelloWorld"

CommandAction="javascript:alert('Hello World!');" />

</CommandUIHandlers>

</CommandUIExtension>

</CustomAction>

</Elements>


 

选项A. Location="DocumentLibrary" 表达是错误的。
CustomAction元素的Location 属性告知 CustomAction 在何处应用自定义项(即此元素内的所有自定义内容)。下表就是此属性相关选项的取值及说明:
                    值
                              说明
CommandUI.Ribbon
对于指定的 RegistrationId,自定义项出现在任何地方。
CommandUI.Ribbon.ListView
当存在列表视图 Web 部件时出现自定义项。
CommandUI.Ribbon.EditForm
自定义项出现在编辑表单上。
CommandUI.Ribbon.NewForm
自定义项出现在新建表单上。
CommandUI.Ribbon.DisplayForm
自定义项出现在显示表单上。
 选项B. RegistrationId="101". 用于指定与此操作(CustomAction )关联的列表或项内容类型的标识符,或文件类型或编程标识符 (ProgID)。 关于它们的含义请参见   Sharepoint学习笔记—Ribbon系列--
Reference :List definitions Type and BaseType ,此设置为101 也即我们自定义的CustomAction与 Document library //文档库 进行关联。也就是说当我们选择Sharepoint网站的某个DocumentLibrary List时,就会出现我们自下定义的CustomAction选项卡(Tab),也就是说,在CustomAction的相关属性设置中,我们解决了它显示的“时机”问题。 
选项C. RegistrationType="List" ,RegistrationType属性: 用于给每项操作指定注册附件。可能的值包括:None,ContentType,FileType,List,ProgId
选项D. ShowInLists="false" 此属性已经弃用,不应该再使用。可选属性,类型为 Boolean。如果仅在用于管理内容类型的页上显示针对列表的自定义操作,则为 TRUE。默认值为 FALSE。
所以本题目正确选项应该是B

参考:
http://techtrainingnotes.blogspot.com/2008/01/sharepoint-registrationid-list-template.html http://msdn.microsoft.com/en-us/library/ff630938.aspx
http://msdn.microsoft.com/en-us/library/ms460194.aspx

 

Question 17

You have one Web application that contains several SharePoint site collections.
You need to create a Feature that adds a custom button to the Documents tab on the Ribbon of one site collection only.
What should you do?
A. Create a new Feature. In a new <CommandUIDefinition> node, specify the location of Ribbon.Tabs._children.
B. Create a new Feature. In a new <CommandUIDefinition> node, specify the location of Ribbon.Documents.Manage.Controls._children.
C. Modify the CMDUI.xml file. In a new <CommandUIDefinition> node, specify the location of Ribbon.Tabs._children.
D. Modify the CMDUI.xml file. In a new <CommandUIDefinition> node, specify the location of Ribbon.Documents.Manage.Controls._children.
 解析:

 本题的题意要是要实现在”某一个” Site Collection中的Ribbonr的Document Tab上添加一个用户自定义的按钮。所以是关于Ribbon的实现的。由要求可知 1. 此按钮并非”通用”的,即适用于所有的Site Collection. 2. 此按钮要出现在Document Tab中。

 明确了要求,我们就可以首先排除C.D了,因为CMDUI.xml中定义的均是Out-Of-Box的Ribbon元素,也即在这里所作的改变均会显示到所有的相关的Site Collecti
f688
on中,具有”通用”性。达不到只针对某个Site Collection的要求。

  然后就是Document Tab的位置要求,本题位置要求应该是Ribbon.Documents. 即选项B符合要求。

至于选项A,是根本不存在Ribbon.Tabs这样的位置定义的。

所以本题目正确选项应该是B 

参考:

http://msdn.microsoft.com/zh-cn/library/ee537543(v=office.14).aspx

http://www.cnblogs.com/wsdj-ITtech/tag/Ribbon/

http://howtosharepoint.blogspot.com/2010/06/ribbon-basics.html
 
Question 18
You have a SharePoint site that contains 10 lists.
You need to prevent a list named List1 from appearing on the Quick Launch navigation bar.
What should you configure? 
A. the Hidden property of List1
B. the Navigation.QuickLaunch.Parent.IsVisible property of the site
C. the OnQuickLaunch property of List1
D. the QuickLaunchEnabled property of the site
 解析:

选项A. List的Hidden Property用于设置这个List是否在Documents page, Lists page, Quick Launch bar, Modify Site Content page, 或者 Add Column page上显示.请注意,它控制的不仅是Quick Launch Bar上是否显示。

选项B. 看表达就知道它控制的并不是List,而是QuickLlaunch对象自身的元素。而且是否有此属性我还并没验证。

选项C. 此属性用于设置指定的List是否在HomePage的Quick Launch 上出现,这正是我们需要的。

选项D. 用于设置Quick Launch area 是否在Web Site上能用(显示与否)。

所以本题目正确选项应该是C

参考

http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.splist.onquicklaunch.aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.onquicklaunch.aspx
http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.spweb.quicklaunchenabled(v=office.12).aspx

 

Question 19
You create a Feature receiver.
You need to hide the Quick Launch navigation bar of a SharePoint site.
What should you use?
A. the Hidden property of each list
B. the Navigation.QuickLaunch.Parent.IsVisible property
C. the OnQuickLaunch property of each list
D. the QuickLaunchEnabled property

解析:

本题想要实现隐藏Sharepoint站点上的Quick Launch navigation bar的效果,

根据Question18,可以直接得出选项D就是我们需要的答案。

Question 20
You create a Feature.
You need to add an item to the context menu of a list.
Which type of element should you use?
A. a CustomAction
B. a ListInstance
C. a ListTemplate
D. a Module

解析:

这是关于Context Menu的操作,一个Custom Action(定义为一个CustomAction元素节)可以被添加到XML文档中(此XML文档是Feature定义的一部分),如下例:

<CustomAction Id="SPTest.CustomMenuItem.ButtonClicked"
RegistrationType="List"
RegistrationId="101"
Location="EditControlBlock"
ImageUrl="/_layouts/IMAGES/DOCLINK.GIF"
Sequence="301"
Title="Click Me!"
Description="Shows an alert message for this Menu Item."
>
<UrlAction Url="javascript:alert('Hello World!');" />
</CustomAction>


这就是一个典型的Custom Context menu item 定义,其中的Registration type 说明了何时这个context menu 会出现(本例就是List被选取时就能使用此Context Menu). 接下来的则定义了此菜单项会进行怎样的操作。所以答案就是选项A.

选项B. ListInstance 是创建一个List实例,与List的Context Menu并没关系。

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Color"
OnQuickLaunch="TRUE"
TemplateType="10050"
Url="Lists/Colors"
Description="A list for colors">
</ListInstance>
</Elements>


选项C. ListTemplate代表的是可用作在“创建”页上创建列表的选项的列表定义(列表模板).

选项D. Moduel指定用于在元素指令清单中设置 SharePoint 网站的文件,可以将零个或多个 File 元素作为 Module 元素的子级。所以本项与List的Context Menu无关。

所以本题目正确选项应该是A

参考:
http://keremozen.com/2012/01/07/custom-context-menu-item-in-sharepoint-2010/
http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-context-menu-item-with-custom-code#.UZGptbLdihk
http://blogs.msdn.com/b/allenwang/archive/2010/09/08/how-to-create-custom-content-type-and-list-instance-in-sharepoint-2010-using-visual-studio-2010.aspx
http://msdn.microsoft.com/zh-cn/library/ms462947.aspx

Question21
You create a custom site definition.
You need to modify the contents of the Quick Launch area.
Which file should you modify?
A. Onet.xml
B. Schema.xml
C. VWStyles.xml
D. WebTemp.xml

解析:

本题要你更改一个Site Definition内的Quick Launch Area, 其实就是考你Site Definition的组成要素。

首先什么是Site Definition呢,微软对其定义就是:Contains a server-side collection of files that defines the structure of one or more site templates.也就是在服务器端包含了若干文件(这些文件就是ASPX页面文件以及XML文件)用于定义一个或多个站点模板的结构。

那么Site Definition的定义都有哪些重要的文件呢?重要的有3个:

1. default.aspx:用于定义网站的默认主页

2. onet.xml:这个最重要,根据 Onet.xml 文件的位置以及它是网站定义还是 Web 模板的一部分(也即不光在Site Definition中有此文件,在Web Template中也会有此文件),该文件中的标记具有下列部分或全部功能:

• 指定基于网站定义或 Web 模板创建的网站中内置的网络范围和网站集范围的功能。

• 指定基于网站定义或 Web 模板创建的网站中内置的列表类型、页面、文件和 Web 部件。

• 定义在主页上和网站定义的列表视图中显示的顶部和侧面导航区域 (正是本题需要操作的功能)。

• 指定每个网站定义中使用的列表定义,以及这些定义是否可用于在用户界面 (UI) 中创建列表。

• 指定网站定义中可用于在 UI 中创建文档库列表的文档模板,以及文档模板中使用的文件。

• 定义从中派生默认 SharePoint Foundation 列表的基列表类型。(仅全局 Onet.xml 文件具备此功能。不能定义新基列表类型。)

• 指定 SharePoint Foundation 组件。

• 定义服务器电子邮件中使用的页脚部分。

使用自定义 Onet.xml 的网站定义任务

可以在用于自定义网站定义或自定义 Web 模板的自定义 Onet.xml 文件中执行下列类型的任务:

•为网站定义指定一个备用级联样式表 (CSS) 文件、JavaScript 文件或 ASPX 头文件。

•修改主页和列表页面的导航区域。

•将新列表定义作为选项添加到 UI 中。

•为网站定义或 Web 模板定义一个 配置,指定实例化配置时包含的列表、模块、文件和 Web 部件。

•指定基于网站定义或 Web 模板创建的网站自动提供的功能。

可在用于自定义网站定义的自定义 Onet.xml 文件中执行下列类型的任务,但不能在用于自定义 Web 模板的 Onet.xml 文件中执行:

•添加用于创建文档库的文档模板。

•为网站定义定义多个 配置,指定实例化配置时包含的列表、模块、文件和 Web 部件。

•为从基于网站定义的网站发送的电子邮件定义自定义页脚。

•.为基于网站定义的网站定义自定义组件,如文件对话框后置处理器。

3. webtemp_SiteDefinitionName.xml : 用于当我们在新创建一个Sharepoint Site时的页面上,有一个Template Selection 区,在此区段的相关模板的配置信息。也即这个文件定义了当前网站定义下有多少个网站模板, 每个模板的名字,描述等. 默认只包含一个站点模板。

实际上,当你打开Visual Studio 2010, 创建一个Site Definition 项目并命名为Demo.SiteDefinition. 选择"deploy as farm solution". 并点击完成. 在项目目录下你就会找到Site Definition节点,展开此节点,你就可以看到这3个重要的组成成员文件了。

从上面的分析,所以我们知道,选项A就是答案。

选项B. Schema.xml : 这是一个List Definition相关文件。列表架构包括字段定义(Field 元素)、视图定义和工具栏定义,并为所创建的列表指定内容类型、表单和默认说明。列表定义包含在位于 %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES 中的 Schema.xml 文件中或包含在沙盒解决方案中。

在List的“创建”页面中显示为选项的每个列表定义都具有一个 Schema.xml 文件,该文件位于 %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES 的子文件夹中或者部署为沙盒解决方案的一部分。

选项C. VWStyles.xml :是List的Default View Style文件(定义List默认视图)。

Sharepoint2003: \\Program Files\Common Files\Microsoft Shared\web server extenstions\60\TEMPLATE\1033\STS\XML\VWSTYLES.XML

Sharepoint2007: \\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\XML\VWSTYLES.XML

Sharepoint2010 \\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\VWSTYLES.XML

选项D. WebTemp.xml: Microsoft SharePoint Foundation 的部署中的每台服务器最初都至少在 %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LCID\XML 文件夹中安装了 WebTemp.xml 文件,其中 LCID 是语言/区域性的数字 ID,例如 1033 表示英语。还可能有一个或多个自定义 WebTemp*.xml 文件。WebTemp*.xml
文件包含网站定义配置的详细列表,当创建新网站时,将在用户界面 (UI) 中提供这些配置以供用户选择。根据是否正在使用 Microsoft Silverlight 或 HTML 网站创建页,UI 会有所不同。不能修改随 SharePoint Foundation 一起安装的原始 WebTemp.xml 文件。因为,当我们为 SharePoint Foundation 安装更新或 Service Pack,或者将安装升级到下一个产品版本时,可能会覆盖对最初安装的文件所做的更改。考虑到这些原因,不支持更改原始 WebTemp.xml
文件。

所以本题目正确选项应该是A

参考:
http://msdn.microsoft.com/en-us/library/dd583160(v=office.11).aspx
http://msdn.microsoft.com/en-us/library/vstudio/ee231576.aspx
http://msdn.microsoft.com/zh-cn/library/ms432370.aspx
http://msdn.microsoft.com/en-us/library/ms460922.aspx
http://msdn.microsoft.com/zh-cn/library/ms459356(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/dd583132(office.11).aspx
http://msdn.microsoft.com/zh-cn/library/ms447717(v=office.12).aspx
http://msdn.microsoft.com/zh-cn/library/ms447717(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/ms474369.aspx

 

Question22
You create a Feature.
You need to remove the link to the Site Content Type page from the Site Settings page by using the Feature.
Which element should you use in the Feature?
A. ContentType
B. ContentTypeBinding
C. HideCustomAction
D. Module

解析:

 本题就是要移除Site Setting页面中的Galleries栏下的Site Content types设置链接。如下图:

 


 实现手段是通过Feature来达到此效果。所以实际要考的是Feature的内容。

所以让我们快速的了解一下关于Feature的概念与特性。

所谓Feature就是我们所说的”功能”,你可以把想要实现的任何效果,操作,资源以及设置等等包装成一个个的”功能”,再部署到Sharepoint网站上,

功能降低了对网站进行简单自定义的复杂性,同时在将升级应用于部署时,功能相当可靠。借助功能,无需再复制大量代码即可更改简单功能。功能减少了前端 Web 服务器中可能出现的版本控制问题和不一致问题。通过功能可以更加轻松地激活或停用部署过程中所应用的功能,并且管理员仅需在用户界面上打开或关闭特定功能,即可方便地转换网站模板或定义。

功能可提供以下内容:

• 用于确定自定义代码运行位置的作用域语义

• 部署中用于安装或卸载功能的可插入行为

• 给定范围内用于激活或停用功能的可插入行为

• 用于在其作用域中存储功能所需数据的作用域属性包

• 用于分布式部署 Microsoft SharePoint Foundation 解决方案的统一框架的基础

不同的功能需要不同的文件格式,具体取决于自定义的类型。以下这是一些功能类型的文件格式:

• 内容类型绑定架构 (本题选项B就在此架构中)

• 自定义操作架构(本题所要实现的功能就在此架构中)

• 内容类型定义 (本题选项A就在此架构中)

• 委派控件

• 文档转换器

• 事件注册

• Feature.xml 文件

• 功能/网站模板关联

• 字段定义

• 列表实例

• 列表模板文件

• 模块(本题选项D就在此模式中)

• 网站定义 (Onet.xml) 文件

• 工作流定义

本题所要实现的功能就在”自定义操作定义架构”中,此架构包含如下元素

  CustomActionGroup:元素包含一组自定义操作的核心定义

  CustomAction:定义用户界面扩展,如工具栏上的按钮或网站设置页上的链接。

  HideCustomAction:元素可以隐藏默认情况下在 Microsoft SharePoint Foundation 功能的基础结构中或其他自定义操作中实现的现有操作。(这正是本题需要的知识点)

选项 A. ContentType ,属于内容类型定义架构中的元素,内容类型定义架构用于定义在功能的元素指令清单文件中创建内容类型的 XML 的结构。其内的ContentType元素用于定义单个内容类型。

B. ContentTypeBinding,属于内容类型绑定定义架构。每个指定内容类型绑定的元素指令清单文件都必须遵守内容类型绑定定义架构。其内的ContentTypeBinding元素用于指定要在 onet.xml 架构中定义的列表上设置的内容类型。

选项C. HideCustomAction就是本题的答案,针对本题的使用代码示例如下:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<HideCustomAction
Id="HideSiteActionFeatures"
HideActionId=" ManageCType "
GroupId="Galleries"
Location="Microsoft.SharePoint.SiteSettings" />
</Elements>


 

D. Module,属于模块格式。所谓模块部分就是按照类似于在 Onet.xml 文件中定义模块的方式在元素指令清单中定义模块,以便指定用于设置 SharePoint 网站的文件。可以将零个或多个 File 元素作为 Module 元素的子级。而Module元素用地指定在元素指令清单中设置 SharePoint 网站的文件。

所以本题目正确选项应该是C

参考:
http://msdn.microsoft.com/zh-cn/library/ms460318(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/ms414790(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/ms414322(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/bb802730.aspx

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息