- 论坛徽章:
- 0
|
Represents a property (meta-information) mapped to a VFS resource.
属性是一个对象,包括3个字符变量,名字name,属性值1property value,属性值2
第一个属性值在资源对象的结构记录之中,属性值2是在资源对象的资源记录
属性对象可以有两个属性值也可以只有一个,但必须至少有一个值.(结构值和资源值的区别,结构是只文件所在的位置的属性值,可以是文件也可以是他sibling(应该相当于快捷方式),而资源值就包括了所有相关的值)
A
property is an object that contains three string values: a name, a
property value which is mapped to the structure record of a resource,
and a property value which is mapped to the resource record of a
resource. A property object is valid if it has both values or just one
value set. Each property needs at least a name and one value set.
A
property value mapped to the structure record of a resource is
significant for a single resource (sibling). A property value mapped to
the resource record of a resource is significant for all siblings of a
resource record. This is possible by getting the "compound value" (see
getValue()) of a property in case a property object has both values
set. The compound value of a property object is the value mapped to the
structure record, because it's structure value is more significant than
it's resource value. This allows to set a property only one time on the
resource record, and the property takes effect on all siblings of this
resource record.
The
ID of the structure or resource record where a property value is mapped
to is represented by the "PROPERTY_MAPPING_ID" table attribute in the
database. The "PROPERTY_MAPPING_TYPE" table attribute (see
STRUCTURE_RECORD_MAPPING and RESOURCE_RECORD_MAPPING) determines
whether the value of the "PROPERTY_MAPPING_ID" attribute of the current
row is a structure or resource record ID.
Property
objects are written to the database using
org.opencms.file.CmsObject.writePropertyObject(String, CmsProperty) or
org.opencms.file.CmsObject.writePropertyObjects(String, List), no
matter whether you want to save a new (non-existing) property, update
an existing property, or delete an existing property. To delete a
property you would write a property object with either the structure
and/or resource record values set to DELETE_VALUE to indicate that a
property value should be deleted in the database. Set property values
to null if they should remain unchanged in the database when a property
object is written. As for example you want to update just the structure
value of a property, you would set the structure value to the new
string, and the resource value to null (which is already the case by
default).
Use
setAutoCreatePropertyDefinition(boolean) to set a boolean flag whether
a missing property definition should be created implicitly for a
resource type when a property is written to the database. The default
value for this flag is false.
Thus, you receive a CmsException if you try to write a property of a
resource with a resource type which lacks a property definition for
this resource type. It is not a good style to set
setAutoCreatePropertyDefinition(boolean) on true to make writing
properties to the database work in any case, because then you will
loose control about which resource types support which property
definitions.
注:opecms 的表cms_offline_properties 中的字段PROPERTY_MAPPING_ID
和表cms_offline_resources or 表cms_offline_structure相关.当PROPERTY_MAPPING_TYPE = 1时 等于resource_id ,当为2时等于structure
哈哈终于找到了表的联系,对OpenCms数据表的研究可以告以段落了呵呵
[/url]
[url=http://hi.baidu.com]OpenCms的org.opencms.flex机制描述
2006-07-14 14:11
王轩 writing
org.opencms.flex Description
opencms把所有的资源储存在OpenCms Database中,叫做VFS。但是JSP engines 只可以读取JSP代码在本地文件系统。解决的方法是把Content
of opencms JSP page 从VFS中导入真实文件系统,然后dispatch如标准的JSP engine.
基本过程是:
Opencms 从OpenCmsServlet中获得请求 被请求的资源被识别为一个JSP page.(资源类型为CmsResourceTypeJsp) JSP装载器启动,并且启动资源管理器CmsResourceManager Jsp装载器实现一个附加的接口 I_CmsResourceLoader 资源装载器是在Flex版本中提出的一个新的接口。主要的区别是 原始的request / response 使用Servlet标准HttpServletRequestWrapper / HttpServletResponseWrapper 当第一次Call一个页面,Jsp page的文章内容用CmsObject从OpenCms Vfs中读出 文
章的内容被写入server的“真实”文件系统。在默认的设置放入目录{WEBAPP-PATH}/opencms/WEB-
INF/jsp/online 当请求Online页面,或 {WEBAPP-PATH}/opencms/WEB-INF/jsp/offline
当请求的为Offline页面。这个目录可以在Opencms.properties中设置 当页面已经写出真实文件系统,装作器分派用标准JSP机制用简单的include()call 标准的Jsp机制会处理JSP,并传送一个输出通过包装的request/response 到OpenCms OpenCms接着传送内容到User
在OpenCms中创建多页面元素JSP模板
Building a complete JSP template with multiple and direct editable page elements
建立有多个可以直接编辑的页面元素的JSP模板
In
the previous step, you have created a complete JSP template with "head"
and "foot" elements. Now we will use this template to make the page
element content directly editable from the frontend and add multiple
page elements on it.
在之前的步骤中,你已经建立了有Head Foot元素的完整JSP模板。现在我们将用这个Template建立可直接编辑的页面元素,并加入多个页面元素。
First,
we must mark the template as "direct editable", this is done by adding
the tag to the HTML head in the template. The
include of the page element itself must be extended with the editable
attribute, both modifications are shown below.
首先,必须标记这个模板是可以"direct editable",方法是把tag加入到模板的HTML head中。页面包含的页面元素
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]http://www.opencms.org/taglib/cms
[color="#3366ff"]" %>
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
">
[color="#3366ff"]../resources/mystyle.css">
[color="#ff0000"]--在头中加入可直接编辑标记
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]My first template head
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#ff0000"]--包含可以编辑body的标记
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]My first template foot
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
The
next extension is the use of multiple page elements in one template.
With the tag, you can add control structures to
the template which allows it to deal with multiple page elements.
另外一个扩展是在一个模板中使用多个页面元素,使用 tag,通过给模板增加控制结构使模板允许处理多页面元素。
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]http://www.opencms.org/taglib/cms
[color="#3366ff"]" %>
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
">
[color="#3366ff"]../resources/mystyle.css">
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]My first template head
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]This is the first page element:
[color="#3366ff"]
[color="#ff0000"] --问题,这个ifexist是个啥意思啊 难道是 if ,exists 如果存在
[color="#ff0000"]This is the second page element:
[color="#ff0000"]
[color="#ff0000"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]My first template foot
[color="#3366ff"]
[color="#3366ff"]
[color="#3366ff"]
As
you can see, everything inside the tag will only be included in the
output, if your page contains a page element named "body2". For a
complete description of all possible control structures, see the
documentation of the tag.
正如你看到的,如果你的页面包括为“body2”的页面元素,所有包含在tag中的元素将只包含在输出中。完整的控制结构的描述参见 tag文档.
Now
that you have modified the template itself, we must tell the editor,
that the template can display a second page element as well. Therefore,
you have to modifiy the value of the template-elements property of the
template to: body*|Body,body2|2nd Body. Page elements that are
mandatory are marked with a star "*", the string after the pipe "|"
specifies the nice name of the element.
既然你修改了模板,就必须告诉编辑器,模板可能可以
显示第二个页元素。因此,你必须修改模板的template-elements属性值,改为body*|Body,body2|2nd
Body。Page elements that are mandatory are marked with a star "*", the
string after the pipe "|" specifies the nice name of the element.
Congratulations! You have succeeded in creating your first "complete" OpenCms JSP template with direct edit and multiple pages.
Now proceed to the last step of the template howto to learn about JSP scriptlet options.
[/url]
[url=http://hi.baidu.com]如何在OpenCms中进行 JSP 模板开发 (JSP template development Howto)
在OpenCms中建立完整的JSP模板
If
you have created a new page that uses the simple template from step 1,
you will have found out that you can edit the content of the page and
that edited content is displayed on the page if you open it in the
preview or the browser. It works perfect for editable HTML pages.
如果你已经创建用了使用简单模板的新页面,你将发现你可以编辑出现在页面上的内容,如果你在浏览器上预览,它能很好的作为Html页面运转
In
this section we will show you how to create a "complete" template. This
is a template that can be used for dynamic JSP as well as for pages
editable with the WYSIWYG editor.
在这里我将像你展示如何建立一个完整的模板,这个模板能用于动态JSP页面,也能用于WYSIWYG编辑器
The example JSP example-jsp-simple.jsp is a simple form. Have a look at the JSP source code:
A simple form
Your name is:
Enter
your name:
It
would be handy using the same template which works for HTML pages as
well as for dynamic JSP pages, to get the same layout. To achieve this,
the JSP template from the previous example must be extended with
tags. Again, please refer to the OpenCms taglib
documentation for all options of the tag.
将相同的模板用于HTML页面是方便的,如同用动态JSP页面。为了得到相同的展示,之前例子的JSP模板必须扩展tags,请参加OpenCms taglib文档中关于的标志。
Here is the "complete" version of the simple template from the previous example. You will find the source code at
/system/modules/com.alkacon.documentation.howto_template/jsptemplates/howto-complete.jsp.
[color="#3366ff"]
[color="#3366ff"]http://www.opencms.org/taglib/cms
" %>
">
../resources/mystyle.css">
My first template head
My first template foot
As
you can see, the only changes are the additional
tags. These tags are required so that the template is usable from a
JSP. They are ignored by the pages that are edited with the WYSIWYG
editor. Assure that all parts of the JSP template are enclosed by
tags.
正如你看到的,唯一的改变是增加的标志。这
些tag是必须的,这样template可以用于JSP。他们被编辑所见即所得的页所忽略。确认,JSP
template的所有部分必须包含在标记中。
To use this adapted template, you just have to add 3 additional lines to your JSP form:
为了使用这个适合的template,你只需要增加这3个附加行到你的JSP列中
[color="#3366ff"]
[color="#3366ff"]http://www.opencms.org/taglib/cms
[color="#3366ff"]" %>
A simple form
Your name is:
Enter your name:
The JSP includes the "head" and "foot" element of the JSP template specified in the "template" property of the JSP.
JSP包含JSP模板的“head”和“foot”,这些属性在JSP“template”属性中指定。
The
last thing required for this template to work correctly is that you
must attach a property "template" to the JSP. The value of the property
must be the filename (including path) of your JSP template, in our
example
/system/modules/com.alkacon.documentation.howto_template/jsptemplates/howto-complete.jsp.
Actually, you can name the property anything you want because the name
is choosen in the property="template" part of the
tag, but we think the name "template" is a good choice for selecting
the template.
最后,你必须将”template”属性附给JSP这样才能使这个模板正常运行,属性的值必须是JSP模板的文件名(包括路径)。在我们的例子中
/system/modules/com.alkacon.documentation.howto_template/jsptemplates/howto-complete.jsp.
实际上你可以给你你的属性起任何名字,因为名字是可选的在标签的(property=”template”)中,但是我们认为把选择模板命名为”template”是一个好的选择。
Note:
Instead of attaching the property "template" to every JSP individually,
you could also attach it to a parent folder. A JSP that does not have
the "template" property set will inherit it from its parent folder.
注:代替将template属性赋给每一个JSP。你也可以付给它的父文件夹。没有设置模板属性的JSP将从它的父文件模板。
The example example-jsp-template.jsp shows the form with the included elements of the JSP template.
Exercise:
Create a JSP using the elements of the shown JSP template
howto-complete.jsp. Include the elements several times in various order
and look at the output. Try to create your own complete JSP template
and define different parts. Create a new JSP and
include your self-defined parts. Also try to use this complete template
for editable pages in the WYSIWYG editor.
Congratulations! You have succeeded in creating your first "complete" OpenCms JSP template.
[/url]
本文来自ChinaUnix博客,如果查看原文请点:[url]http://blog.chinaunix.net/u/24141/showart_287947.html |
|