Description
A
resource
is a administrative object that stores binary files of any type and size. apps use resources to display output to a standard Web browser or a small LCD device by providing components for Web pages.
They can be any resource that you use in a Web application, including:
-
GIF
-
JPEG
-
MPEG
-
AVI
-
WAV
-
JAR
-
CAB
For example, you can include in the database a resource that represents the company corporate logo. In a Web application, the company corporate logo could be referred to many times.
The resource editor allows you to name the administrative definition, give it a description, and define a MIME (Multi-Purpose Internet Mail Extension) type that is used to ensure that the browsers know what kind of component this is. For example, the company corporate logo could be an
image/gif
MIME type, indicating that it is a .gif file that should be rendered in the browser.
You can use standard MQL commands such as create, delete, copy, modify, print, and list to manage resources. Specialized functions and embedded commands facilitate evaluation, translation, or formatting of objects or output on HTML pages.
User Level
Business Administrator
Syntax
The command uses this syntax.
-
NAME
is the name of the resource you are defining. The name you choose is the name that will be referenced to include this resource within a Web page. Resource names must be unique. For more information, see About Administrative Object Names.
-
CLAUSEs provide additional information about the resource.
Add Resource
Use the Add Resource command to define a new resource:
Syntax
add resource NAME [ADD_ITEM {ADD_ITEM}]; |
NAME
is
the name you assign to the resource. ADD_ITEM
is an Add Resource clause that provides additional information about the resource you are defining. The Add Resource clauses are:
All clauses are optional for defining a resource, since the resource can later be modified. To be used in a web page, at least the file and MIME type must be defined.
File Clause
This clause defines the binary file that contains the resource. This is often a .gif or other image file, but they can be any resource that you use in a Web application.
For example, to define a resource for the company logo, you could use: add resource Logo
file Matrixlogo.gif; |
Mime Clause
This clause associates a MIME (Multi-Purpose Internet Mail Extension) type with a resource. It defines the content type of the file. -
VALUE
is the content type of the file. The format of
VALUE
is a type and subtype separated by a slash. For example, image/gif or video/mpeg.
The major MIME types are application, audio, image, text, and video. There are a variety of formats that use the application type. For example, application/x-pdf refers to Adobe Acrobat Portable Document Format files. For information on specific MIME types (which are more appropriately called “media” types) refer the Internet Assigned Numbers Authority Website at
http://www.isi.edu/in-notes/iana/assignments/media-types/. The IANA is the repository for assigned IP addresses, domain names, protocol numbers, and has also become the registry for a number of Web-related resources including media types.
History Clause
The
history
keyword adds a history record marked “custom” to the resource that is being added. The
STRING
argument is a free-text string that allows you to enter some information describing the nature of the addition. For more information, see Adding History to Administrative Objects.
Copy Resource
After a resource is defined, you can clone the definition with the Copy Resource
command.
Syntax
This command lets you duplicate defining clauses with the option to change the value of clause arguments:
copy resource SRC_NAME DST_NAME [MOD_ITEM {MOD_ITEM}]; |
SRC_NAME
is the name of the resource definition (source) to copied.DST_NAME
is the name of the new definition (destination). MOD_ITEMs are modifications that you can make to the new definition. For more information, see Modify Resource.
History Clause
The
history
keyword adds a history record marked “custom” to the resource that is being copied. The
STRING
argument is a free-text string that allows you to enter some information describing the nature of the copy operation. For more information, see Adding History to Administrative Objects.
Modify Resource
Use the Modify Resource
command to change the definition of an existing resource.
This command lets you add or remove defining clauses and change the value of clause arguments:
modify resource NAME [MOD_ITEM {MOD_ITEM}]; |
NAME
is the name of the resource you want to modify.MOD_ITEM
is the type of modification you want to make. You only need to specify the fields to be modified. Modify Resource Clause | Specifies |
---|
name NEW_NAME | The current resource name changes to the new name entered. | description VALUE | The current description value, if any, is set to the value entered. | icon FILENAME | The image is changed to the new image in the field specified. | file FILENAME | The resource file is changed to the new file specified. | mime VALUE | The mime type for the resource is changed to the new value specified. | hidden | The hidden option is changed to specify that the object is hidden. | nothidden | The hidden option is changed to specify that the object is not hidden. | property NAME [to ADMINTYPE NAME] [value STRING] | The named property is modified. | add property NAME [to ADMINTYPE NAME] [value STRING] | The named property is added. | remove property NAME [to ADMINTYPE NAME] [value STRING] | The named property is removed. | history STRING | Adds a history record marked "custom" to the resource that is being modified. The STRING argument is a free-text string that allows you to enter some information describing the nature of the modification. Fore more information, see Adding History to Administrative Objects. |
Each modification clause is related to the clauses and arguments that define the Resource.
Delete Resource
If a resource is no longer required, you can delete it using the
Delete Resource command.
NAME
is the name of the resource to be deleted.
This command searches the list of defined resources. If the name is found, that resource object is deleted. If the name is not found, an error message is displayed.
For example, to delete the Logo resource, enter the following command:
After this command is processed, the Logo resource object is deleted.
Resource Usage
For global database access, resources generally need to be provided in multiple languages. And with the wide use of cell phones and other hand-held devices in accessing Web pages, you might also need to support the resource’s display on a small LCD in wireless markup language (wml).
When this is the case, you can use the following Studio Customization Toolkit call to open a resource with a language and format argument, following the syntax: open(BASE_RESOURCE_NAME, LANG, MIMETYPE) |
For example:
When evaluating this code, the resource servlet first looks for the file named
logo_fr_wml.gif . If the servlet does not find this resource object, it attempts to find
logo_wml.gif . As a last resort, it searches for the resource
logo.gif . Of course, you could call
login_fr_wml.gif
directly, but the addition of arguments gives you much more flexibility when writing the code.
In this case, you would first create
logo.gif , and then create the wireless version of the resource (generally a much smaller version) and name it
logo_wml.gif . Then, for each language that requires a different version of the resource (a translated textual image, a sound byte, or even a pure image that, due to cultural differences, requires a localized version) you would create the different resource files and reference them in a new resource object and save as
logo_LANG.gif
and
logo_LANG_wml.gif . For example, to support multiple languages, you could have resources with the following names in the database: logo.giflogo_ch-tw.giflogo_ch-gb.giflogo_it.gif |
To add support for wml, you might add the following resource:
In this case, all languages would use the same wml resource.
The base resource does not have to be in English. Also, the LANG argument could be more than two characters, such as en-us, en-uk, or ch-tw.
|