1. Trang chủ
  2. » Công Nghệ Thông Tin

Quản lý cấu hình web - part 13 pot

10 265 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Quản lý cấu hình web - part 13 pot
Trường học University of Information Technology
Chuyên ngành Web Configuration Management
Thể loại Bài viết
Năm xuất bản 2023
Thành phố Ho Chi Minh City
Định dạng
Số trang 10
Dung lượng 5,64 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

By the end of this chapter, you will have learned how to: • Create web forms • Create rendition templates • Create FreeMarker templates • Create Extensible Stylesheet Language transforma

Trang 1

Getting Started with Alfresco WCM

[ 102 ]

Virtual server JSP support

Create a simple "hello world" JSP, load it up, and test The JSP will evaluate without creating the WEB-INF and web.xml files But more complex WARs will need WEB-INF

and web.xml files for Tomcat to evaluate

Previewing WARs and getRealPath()

For JSP and Java code that use the getRealPath() method or the filesystem path for a file, Alfresco requires additional configuration for the virtual server preview to function This is the case for Spring-based web applications, where configuration and properties files are required to be read on startup

To enable preview in this case, Alfresco needs to be modified to:

Enable Alfresco to use CIFS (refer Chapter 2 for details)

• Mount the CIFS directory

• Have the virtual server mount the AVM CIFS projection

Virtual server configuration

The virtual server needs to be configured to mount the new drive Follow these steps:

1 Open up the alfresco-virtserver.properties file in the directory:

c:\Alfresco\virtualtomcat\conf

2 Locate the following section:

#

# On Windows, the ".unix" properties are ignored.

# On Linux, the ".win" properties are ignored.

#

alfresco.virtserver.cifs.avm.versiontree.win=v

alfresco.virtserver.cifs.avm.versiontree.unix=/media/alfresco/ cifs/v

3 Modify alfresco.virtserver.cifs.avm.versiontree.win=v to use the drive letter "Z" used above when mapping to the CIFS server, as follows:

alfresco.virtserver.cifs.avm.versiontree.win=z:

Trang 2

Chapter 3

[ 103 ]

Search

Searching against a WCM store is the same as searching against a full repository However, the scope of the search will be limited to that web project only

A search against an AVM store can be performed via Java, JavaScript, FreeMarker template, or the node browser It is not yet exposed via open search As the API is the same, searches via web services or something similar are the same apart from the store context

Search is only available for the latest snapshot of the head revision for staging It is not available for User Sandboxes, workflow sandboxes, and so on In a lot of cases, the design principle followed is to use Lucene queries minimally in your project Other methods such as navigating via AVM Paths and others to get hold of the content you are trying to search can suffice in such a scenario

Summary

Alfresco tracks all content modifications made within a user's sandbox and maintains those changes in isolation from other user's working within their own sandbox environment In this way, large teams of users can work independently on changes

to the website without stepping over one another's work

Sandboxed development, along with virtualization and in-context preview, means that a large, diverse web team can easily collaborate on changes to the website with reduced risk and higher overall quality

The next chapter will explain in detail the concepts we have covered in this chapter Creation of web forms from scratch, web projects, and content creation using the same is explained in great detail It will take you through concepts of templating, associating templates with web projects, dashlets, dynamic content, and so on

Download from Wow! eBook <www.wowebook.com>

Trang 4

Web Content Production with

Web Forms

In the previous chapter, we learned about creation of a web project To set up a

website you must have both web forms and a web project Web forms provide the facility to manage content through a user-friendly and technology-neutral (as much

as possible) interface It allows you to separate content from code and presentation logic It allows non-technical content owners to manage, approve, and deploy their own web content Static content is required for a few websites However, for many sites, dynamic and flashy content is required Dynamic content can be managed easily with web forms, as content can be created once and rendered in many formats

In this chapter, you will learn about basic and advanced web form concepts and the ways to extend it as per your business requirements

By the end of this chapter, you will have learned how to:

• Create web forms

• Create rendition templates

• Create FreeMarker templates

• Create Extensible Stylesheet Language transformations

• Associate web forms and renditions for specific or multiple projects

• Update web forms and rendition templates

• Create dynamic content

• Create web publishing dashlets

Download from Wow! eBook <www.wowebook.com>

Trang 5

Web Content Production with Web Forms

[ 106 ]

Why web forms

Consider a website, say, www.cignex.com, which has some primary sections, such as news, blogs, events, trainings, and solutions The news, blog, and training elements have to be updated every month Let's assume that in the structure of news element there should be a title, news headline, sub headline, page content, image, image title, and news date For each content of the news, you must have these elements To update these sections, each time you have to create new HTML/JSP files from scratch This becomes quite clumsy We need a way to manage it easily Assume the concept where the structure is in place and you have to just put in the content The concept can be called web forms Another important thing to focus on is the fact that web forms are always stored in XML (Extensible Markup Language) format Using web scripts, you can extract the web content (which is in XML format) and serve external applications Thus you can consider the user interface to be in various technologies that will enable content to be used for various purposes wherever required Content can be transactionally deployed to static content servers or Alfresco runtime

repositories, providing complete architectural flexibility for web forms

These enhanced capabilities make it easier for authorized users to preview and edit various file types, including those with multi-language content, before publishing The new capabilities would allow contributors to preview pages rendered with different file formats, including HTML, PDF, RTF, XML, and mobile, as well as any UTF-8 compatible foreign language formats

Following are the benefits of web forms:

Easily extensible solutions: This will allow users to separate content from

code and presentation logic Thus, content contributors can easily manage the website without developer intervention

• You can display the content in various formats

Easy integration of external systems: Web forms are stored in XML

format, which gives the advantage of platform and language-independent technology, thus making the content available to any web technology (PHP, Python, J2EE, AJAX, Flash, Cold Fusion, and so on)

Asset reusability: Static and dynamic include of the content makes the

structure simpler

• It provides a rapid learning curve Developing and maintaining Alfresco web forms require basic skills in XML, XSD, XSLT, and FreeMarker

Trang 6

Chapter 4

[ 107 ]

The following diagram shows how to access content from the Alfresco repository to

an external application:

Introduction to web forms

Web forms are also known as WCM forms Web forms are used to capture content

from the user and store it as Extensible Markup Language (XML) in Alfresco The XML content is created based on an XML Schema Definition (XSD) Web forms

can be rendered as user-friendly web-based forms Web forms can be associated with multiple rendition templates to render web content in various formats, such as plain text, HTML, JSP, and PDF Out of the box, it supports three types of rendition

engines: Extensible Stylesheet Language Transformations (XSLT), FreeMarker, and Extensible Stylesheet Language Formatting Objects (XSL-FO) Web forms are stored in the Web Client Extension space within Company Home | Data Dictionary

| Web Forms Web forms can be configured to any number of projects As web

forms are located in the Alfresco space, they can be accessed by the default CIFS, FTP, and WebDAV interfaces

Creating web forms

Let's take the same example as mentioned previously, of the Cignex website We will create web forms for the blogs and news sections Also, we will associate these web forms with the rendition templates Finally, we will create content using web forms and preview it

Download from Wow! eBook <www.wowebook.com>

Trang 7

Web Content Production with Web Forms

[ 108 ]

The process to define and create web forms in Alfresco is as follows:

1 Identify structure to be used for each web form

2 Define your XSD file

3 Create a web form using XSD

Identifying the structure to be used for each web form

To create a web form you are required to create an XML Schema Definition (XSD) file with an extension as xsd XSD specifies how to formally describe the elements

in an XML document Before creating an XSD file you will need to decide what all user interface components you want to display in a web form To create a schema for a web form, you analyze its structure defining each structural element as you encounter it As mentioned previously, we will create web forms for the news and blogs sections Consider that some of the elements that are required in creating an XSD file for news are: Brief Title, News Page Headline, News Page Sub Headline, News Page Content, News Article Graphic, Image Caption, Image Title, and News Date Now that you have decided the elements, you will learn how to create an XSD file for simple user interface controls You will know more about advanced controls

in the short while

Defining a schema

To create an XSD file we have to start with the standard XML declaration followed

by the xs:schema element that defines a schema:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema

xmlns:trn="http://www.alfrescobook.com/webforms"

xmlns:alf=http://www.alfresco.org

targetNamespace="http://www.alfrescobook.com/webforms"

elementFormDefault="qualified"

>

</xs:schema>

In the previous schema, we use the standard namespace (xs), and the URI associated with this namespace is the schema language definition, which has the standard value of http://www.w3.org/2001/XMLSchema It is important to specify a

namespace (xlmns:trn) for your web forms to eliminate collisions You can have the same namespace for a specific development project We will use this element while generating renditions The alf namespace is added to enable label, alert, and appearance elements while writing an XSD

Trang 8

Chapter 4

[ 109 ]

Defining a complex element

Now we can define elements inside a complex element First we have to define a root element Let's define news as a root element This element has an attribute and

it contains other elements, therefore we consider it as a complex type The child elements of the news element are surrounded by an xs:sequence element that defines an ordered sequence of sub-elements The syntax for defining a complex element is:

<xs:element name="news">

<xs:complexType>

<xs:sequence>

</xs:sequence>

</xs:complexType>

</xs:element>

Defining a simple element

We can also define a few simple elements inside the complex element Simple

elements are those elements that do not contain any attribute Each element

is defined with a name and type Let's define a few simple elements such as

shortTitle, contentHeader, contentSubHeader, contentText, and so on

The syntax for defining a simple element is:

<xs:element name="shortTitle" type="xs:normalizedString"/>

Here shortTitle is the name of the element and normalizedString is the data type of the element Following is an example of simple elements defining inside complex elements

<xs:element name="news">

<xs:complexType>

<xs:sequence>

<xs:element name="shortTitle" type="xs:normalizedString "/> <xs:element name="contentHeader" type="xs:normalizedString "/> <xs:element name="contentSubHeader" type="xs:string"/>

<xs:element name="contentText" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

An XML schema has a lot of built-in data types Each of these data types has a default widget rendering within the generated XForm in Alfresco

Download from Wow! eBook <www.wowebook.com>

Trang 9

Web Content Production with Web Forms

[ 110 ]

The following table shows the associated widgets with the most commonly used XSD data types:

xs:normalizedString Textbox

xs:string, xs:anyType WYSIWYG editor, Text area xs:date Calendar control

xs:anyURI Asset picker

xs:integer, xs:float, xs:double, xs:decimal Slider control

xs:enumeration Radio button, Drop down

Now we will learn a few attributes that can be applied to an element in order to make it mandatory, optional, default value, or fixed value

Default and fixed values for elements

An attribute may have a default or fixed value A default value is automatically assigned to the element and you can specify any other value A fixed value is also automatically assigned to the element, but you cannot specify another value This can be considered as a read-only value Following is the code snippet for defining default value

<xs:element name="contentHeader" type="xs:normalizedString"

default="News Full Headline">

Optional and required values for elements

We can define the number of possible occurrences for an element with the maxOccurs

and minOccurs attributes maxOccurs specifies the maximum number of occurrences for an element and minOccurs specifies the minimum number The default value for both maxOccurs and minOccurs is 1, which means the field is mandatory

To set the element as optional, you have to set the value of minOccurs to 0 as follows:

<xs:element name="contentSubHeader" type="xs:string" minOccurs="0" maxOccurs="1">

Trang 10

Chapter 4

[ 111 ]

The element can appear multiple times by setting the maxOccurs attribute of the element to "unbounded", which means that there can be as many occurrences of the element as the content contributor wishes We can also fix the occurrences of the element by specifying any number

Advanced schema attributes

There are some advanced schemas attributes provided that will enhance the

capabilities provided within a form For instance, you may want to display images

in the web form You may also think of validation in the web forms that will validate your content For this, you are required to customize some of the widgets

in web forms

File pickers

Alfresco uses the xs:anyURI data type to overcome limitations such as inter-document relationships Although XML standards do exist for defining relationships (XPointer and XLink), both are stagnant (no updates since 2001) and neither has achieved

widespread adoption:

<xs:element name="contentGraphic" type="xs:anyURI" />

This results in an "asset picker" widget, which will allow the content contributor

to browse and select content from the web project The following code snippet provides the ability to specify an image picker to get the images from any folder

in the web project:

<xs:element name="contentGraphic" type="xs:anyURI" minOccurs="0" maxOccurs="1"

<xs:annotation>

<xs:appinfo>

<alf:label>News Article Graphic</alf:label>

<alf:appearance>image_file_picker</alf:appearance>

</xs:appinfo>

</xs:annotation>

</xs:element>

Download from Wow! eBook <www.wowebook.com>

Ngày đăng: 05/07/2014, 20:21

TỪ KHÓA LIÊN QUAN