版权所有:(xiaodaoxiaodao)蓝小刀 [email protected]
http://www.blogjava.net/xiaodaoxiaodao/archive/2007/11/17/161240.html
转载请注明来源/作者
alfresco WCM 在表单中自定义下拉框
alfresco 中使用WCM创建content的时候,如何在表单中使用自定义下拉框。
假设有一个webform,名称为news,使用news.xsd。我们知道xsd文件可以使用:
< xs:include schemaLocation =" /select_list_choices.xsd "/>
include 一个xsd, select_list_choices.xsd 代码如下 ( 注意,下面的下拉框选择项比较少时,比如5个可能不会显示为下拉框,而是显示为radio button):
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:alf="http://www.alfresco.org" elementFormDefault="qualified">
<xs:simpleType name=" select_list_choices ">
<xs:restriction base="xs:string">
<xs:enumeration value="channel01">
<xs:annotation>
<xs:appinfo>
<alf:label> 财经新闻</alf:label>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="channel02">
<xs:annotation>
<xs:appinfo>
<alf:label> 娱乐新闻</alf:label>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="channel03">
<xs:annotation>
<xs:appinfo>
<alf:label> 体育新闻</alf:label>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:schema>
上面的 下拉框是静态的,要想自定义, 则可以在news.xsd中include一个jsp,在jsp中包含所需要的xsd代码。
现在我们自定义一个下拉框,创建一个新的webform,例如名称为channel-list,使用channel-list.xsd:
<?xml version="1.0"?>
< xs:schema xmlns:xs =" http://www.w3.org/2001/XMLSchema " xmlns:cm =" http://www.lively.com/alfresco/cm " targetNamespace =" http://www.lively.com/alfresco/cm " elementFormDefault =" qualified ">
< xs:element name =" select_list ">
< xs:complexType >
< xs:sequence >
< xs:element name =" options " maxOccurs =" unbounded ">
< xs:complexType >
< xs:sequence >
< xs:element name =" value " type =" xs:normalizedString "/>
< xs:element name =" label " type =" xs:normalizedString "/>
< xs:element name =" description " type =" xs:normalizedString "/>
</ xs:sequence >
</ xs:complexType >
</ xs:element >
</ xs:sequence >
</ xs:complexType >
</ xs:element >
</ xs:schema >
使用这个webform创建content,比如创建在 /content/news 目录下,这些创建的数据就是下拉框中使用的内容,如上所示,下拉框使用value/label/description三个元素。则可以使用一个get_channel_list.jsp来取得这些创建的下拉框列表:
< jsp:root version =" 1.2 "
xmlns:jsp =" http://java.sun.com/JSP/Page "
xmlns:c =" http://java.sun.com/jsp/jstl/core "
xmlns:cm =" http://www.lively.com/alfresco/cm ">
< jsp:directive.page language =" java " contentType =" text/html; charset=UTF-8 "/>
< jsp:directive.page isELIgnored =" false "/>
< c:set var =" path " value =" ${param['path']} "/>
< c:if test =" ${empty path} ">
< c:set var =" path " value =" /content/news "/>
</ c:if >
< c:set var =" contentType " value =" ${param['ctype']} "/>
< c:if test =" ${empty contentType} ">
< c:set var =" contentType " value =" channel-list "/>
</ c:if >
< xs:schema xmlns:xs =" http://www.w3.org/2001/XMLSchema "
xmlns:alf =" http://www.alfresco.org "
elementFormDefault =" qualified ">
< xs:simpleType name =" select_list_choices ">
< xs:restriction base =" xs:normalizedString ">
< c:forEach items =" ${cm:getSelectList(pageContext,contentType,path)} " var =" options ">
< jsp:element name =" xs:enumeration ">
< jsp:attribute name =" value ">< c:out value =" ${options.value} "/></ jsp:attribute >
< jsp:body >
< xs:annotation >
< xs:appinfo >
< alf:label >< c:out value =" ${options.label} "/></ alf:label >
</ xs:appinfo >
</ xs:annotation >
</ jsp:body >
</ jsp:element >
</ c:forEach >
</ xs:restriction >
</ xs:simpleType >
</ xs:schema >
</ jsp:root >
上面的cm标签是我们自己定义的,可以参看附件(注意:可以在http://forge.alfresco.com/projects/wsf/上下载wsf1.5最新源码)。
最后,在xsd中引入这个get_channel_list.jsp:
< xs:include schemaLocation =" / get_channel_list.jsp "/>
……
< xs:element name =" channel " type =" news: select_list_choices "/>
……
这样一个自定义的下拉框就可以实现了。
附: alfresco 比较重要的几个地址
官方wiki: http://wiki.alfresco.com/wiki/Main_Page
论坛 : http://forums.alfresco.com/
官方 forge : http://forge.alfresco.com/
alfresco 下载地址 : http://sourceforge.net/project/showfiles.php?group_id=143373
alfresco WCM在表单中自定义下拉框.pdf 下载地址:
alfresco WCM在表单中自定义下拉框.rar
使用的代码下载地址:
alfresco WCM在表单中自定义下拉框_source.rar
版权所有:(xiaodaoxiaodao)蓝小刀 [email protected]