The InternationalFragment Object

An InternationalFragment has exactly the same functionality as the Fragment object. The difference is in the loading of the file.

Refer to the Fragment object for details of the functionality.

InternationalFragment objects are of class Fragment.


The InternationalFragment Constructor

Using the new Operator with the InternationalFragment Constructor

The InternationalFragment constructor is used to create new Fragment objects in an international way.

An InternationalFragment object is loaded using the script locale in the same manner as for InternationalTokens objects. This allows the developer to produce multiple copies of the Fragment for different languages and have the correct Fragment selected by the users browser configuration at run time.

e.g.

myFragment_en_us.html

American English fragment file

myFragment_fr_ca.html

French Canadian fragment file

myFragment_ja.html

Japanese fragment file

myFragment_zh.html

Chinese fragment file

The table above shows a set of fragment files for English, French, Japanese and Chinese. When creating an instance of this fragment the name used would be 'myFragment.html' and the script server will search for a file with the appropriate locale for the users browser. You should have a default fragment file without the locale part of the name for locales that you do not support.

var myInternationalFragment = new InternationalFragment(name[, arg1[, arg2......]]);

A new Fragment object for the file identified by the name is created. The file holds the HTML and script code for the fragment. The name uses the script file reference to identify the file. Absolute file references can not be used for Fragments and all Fragment files must be under the servlet web application root. If the Fragment file does not exist then a runtime error is generated and the script stops processing.

The arguments following the name (if any) are passed on to the constructor function inside the fragment when the Fragment object is created.

The name of the Fragment is the name of the file that holds the HTML and script code not including the locale part (e.g. _en_us). The name uses the script file reference to identify the file.

The InternationalFragment constructor will attempt to run the Fragment constructor function in the same way as the Fragment constructor.

Shown below is the InternationalFragment object prototype chain. Note that this is the same as the Fragment object because the InternationalFragment constructor actually creates Fragment objects.

Calling the InternationalFragment Constructor as a Function

When the constructor is run as a function without the new operator it has exactly the same behaviour as using the new operator.

InternationalFragment Constructor Properties

The InternationalFragment constructor has no predefined properties. In particular it does not have a prototype property. This is because there can be many different Fragment objects (each identified by its file name) and each one can have its own prototype. To set the prototype for all Fragments of a particular type use the setPrototype function (see below).

It is not possible to add new properties to the Constructor.

InternationalFragment Constructor Functions

Property

Description

getPrototype(name)

Returns the prototype object for the Fragment objects identified by the name. The name is the name of the fragment file and uses the script file reference to identify the file.

If the Fragment file does not exist then a runtime error is generated and the script stops processing.

setPrototype(name, prototype)

Set the prototype for the Fragment objects identified by the name to the new prototype. The name is the name of the fragment file and uses the script file reference to identify the file. Returns true if the prototype was set successfully.

If the Fragment file does not exist then a runtime error is generated and the script stops processing.

setPrototypeProperty(name, propertyName, propertyValue)

Set a property identified by propertyName to the propertyValue in the Fragment prototype for the Fragment identified by the name. The name is the name of the fragment file and uses the script file reference to identify the file. Returns true if the prototype property was set successfully.

If the Fragment file does not exist then a runtime error is generated and the script stops processing.

Comment on this topic

Topic ID: 150062