Property "Required Items" <reqitems>

Top  Previous  Next

This property is used to define the files required by the element. The files are copied to the target directory during compilation.

Example:

 

  <form name="myelement">

    <reqitems>

      <item name="pic">mypic.gif</item>

      <item name="script" item-type="script">myscript.js</item> <!-- (1) -->

      <item name="styles" item-type="css">mystyles.css</item>

 

      <item name="templates" item-type="xsltemplate">mytemplates.xsl</item>

      <item name="jar" target-prefix="\WEB-INF\lib\">myappl.jar</item> <!-- (2) -->

      <item name="messages" source-prefix="..\" 

            target-prefix="\WEB-INF\MM-INF\resources\">messages.res</item> <!-- (3) -->

    </reqitems>

  </form>

 

 

The attributes of item tag

<item name="templates" item-type="xsltemplate">mytemplates.xsl</item>

 

name

The name of the item. Each item under the reqitems tag must have a unique name.

item-type

If the item should be linked to the page where the element is used then we should define an item-type attribute. The valid values for this attribute are: "xsltemplate", "script" and "css"

source-prefix and target-prefix

These attributes are required when the relative location of the item on the web server is not the same as the location of the item in the project or library directory. If, in the above example, "myelement" is located under \cpn\mycompany\myappl  library path then myscript.js (1) will be copied to the same path on the web server, so the file name on the web server will be /cpn/mycompany/mayappl/myscript.js

We can change this relativity using target-prefix and source-prefix attributes as exampled with (2) and (3)

 

Source

Target

(2)

\cpn\mycompany\myappl\myappl.jar

/WEB-INF/lib/myappl.jar

(3)

\cpn\mycompany\messages.res

/WEB-INF/M-INF/resources/messages.res

 

Usage of "\%%\" symbol in item value (Supporting multi-lingual elements)

"\%%\" symbol has a special meaning when used in the value of an item definition. Lets try to explain this with an example.

<form name="myelement">
  <reqitems>
    <item name="resources" item-type="script">scripts\%%\MyScript.js</item>
  </reqitems>
</form> 

Assume that the language of the page where this element is used is German "de". When compiling the page MoreMotion Application Studio will replace "\%%\" charactes in the file name with "\de\" and check to see if file "scripts\de\MyScript.js" exists. If yes then it will use it, If no then it will use "\en\" and it will expect the file "scripts\en\MyScript.js" exists.

Knowing this feature of Application Studio, the element developers can prepare a default file. e.g. files\en\name.ext and make the item definition as

  <item name="ef1">files\%%\name.ext</item> 

 

to let the users of the library element to introduce their own language versions of the name.ext file.

See Properties Exclusive to Library Elements.