Cmobilecom AF 5.19 Developer Guide

21.14 Embedded Objects - Text File

A text file can be embedded. docBase is the base dir of files, and filePath is the relative path under the docBase. filePath supports request parameters. #{param.Foo} will be resolved to be the value of request parameter Foo.

For example, load foo/bar.xml under www/docs/userGuide into a textArea.


	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="object1" type="textFile">
		<docBase>#{dataAccessUnit.home}/www/docs/userGuide</docBase>
		<filePath>foo/bar.xml</filePath>
		<charset>UTF-8</charset>
		<mimeType>text/xml</mimeType>
		<preText><![CDATA[<textArea readonly rows="10" cols="120">]]></preText>
		<postText><![CDATA[</textArea>]]></postText>
	</object>
charset is file encoding. mimeType can be text/html, text/plain or text/xml. By default, mimeType is text/html, and the text will not be escaped. The text will be escaped for mime type text/xml and text/plain.

preText is the text that will be added to the beginning of the text. postText is the text that will be appended to the end of the text. both preText and postText are optional.

Example: suppose there is a user guide directory under site "docs" directory:
	#{dataAccessUnit.home}/www/docs/
		userGuide/
			index.html
			examples/example1.html
			examples/example2.html
			images/image1.gif
			css/example.css
The URL pattern is /docs/userGuide/[filePath]. So the URL rewriting rule is:

	<url-rewriting>
		<rule>
			<pattern>^/docs/userGuide/(.+)\.html$</pattern>
			<page>/index.xhtml</page>
			<parameter name="pageIdentifier">/docs/userGuide.xpg</parameter>
			<parameter name="filePath">$1.html</parameter>
		</rule>
	</url-rewriting>
The URL /docs/userGuide/examples/example2.html will be rewritten as:
	/index.xhtml?pageIdentifier=/docs/userGuide.xpg&filePath=examples/example2.html
Embed the HTML user guide into page /docs/userGuide.xpg that can be shown in page container with main menu and page header/footer. (refer to "Page Container" in Website module docs)

/docs/userGuide.xpg:


	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="textFile1" type="textFile">
		<docBase>#{dataAccessUnit.home}/www/docs/userGuide</docBase>
		<filePath>#{param.filePath}</filePath>
	</object>
#{param.filePath} is the value of the created request parameter "filePath". so the physical file to be embedded for the URL /docs/userGuide/examples/example2.html is
	#{dataAccessUnit.home}/www/docs/userGuide/examples/example2.html
Resource files (e.g., images, css) may be referenced in embedded HTML files. For example. The content of /docs/userGuide/examples/example2.html contains:
	<img src="../images/image1.gif"/>
The image URL resolved by web browser is /docs/userGuide/images/image1.gif that will be handled directly by Website module without URL rewriting.

See Website module docs for more information.

Embedded Objects: Inline TextExtensionsFrames / No Frames