|
||||||||||||||
<tml:action>Avaliable since version 2.0.2Description:
Defines a TML-Action. TML-Actions are TMLScript-Functions, that are invoken, when a Link referencing the action, is clicked (see <tml:url/>). When clicking, the page is loaded anew and the TMLScript code is executed before re-rendering the page content.
Attributes:
Details:
There are three options of usage:
Examples:
1. An action can be predefined via <tml:action> and be referenced by other tags on the WebTML-Page, e.g. <tml:url/> or other <tmL:action/>-Tags, to create URLs to invoke the action. In this option, the <tml:action>-Tag does no output itself but only defines the action . Therefore the action is given an ID (see Example 1) The following options are new since WGA Publisher 2.1.1 2. A <tml:action>-Tag can be used, tro create actions invoked by client side JavaScript. The tag therefor creates a so called "Action-Link". This is a text code, containing everything necessary to invoke the action. This text can be passed to a JavaScript function "callAction" (that is predefined via WebTML-Element "htmlhead"), as a parameter, to invoke the action. "callAction" can be invoked by any JavaScript code. To choose this option, the ID attribut is either omitted, or the attribute output="true" is explicitly set. (see Example 2) 3. As a variant to option 2, the <tml:action>-Tag can reference other actions, instead of defining them itself. Is an action defined via Option 1 and should be used in client side JavaScript code later, the action tag gains another attribute "ref", containing the ID of the action to be invoked. In this option, the <tml:action>-tag can also contain parameters for the action via attributes param1 to param5. (see Example 3)
<tml:action id="odor">
this.profile.save() <a href="<tml:url type="action" action="odor"/>">Write to Profile</a> Creates a link with label "Write to profile". When clicking this link, the page is called again, and the TMLScript-Action is invoked before rendering. In this case, the value 4711 is written to the field "odo" in the profile document.
<option value="xxx">.... </select> In this example an TML-Action should be called, when the content of a HTML-Choice field changes. For this purpose, the JavaScript event "onChange" calls the JavaScript function "callAction". This is predefined by WebTML-Element "htmlhead", that should be included in every HTML-Page. As a parameter a string is passed to that function, that is generated by the <tml:action>-Tag. it should be noted, that therefor the <tml:action>-Tag is surrounded by single quotation marks ('). The contents of the tag defines the action, that is executed be calling "callAction".
<tml:action id="validateAndSave"> if (this.tmlform.firstname == '') { this.setvar("error", "The first name must be entered"); } else if (this.tmlform.surname == '') { this.setvar("error", "The surname must be entered");
else { this.tmlform.storeInProfile(); } </tml:action> <!-- Output of error message --> <p style="color: red"><tml:item name="error"/></p> <!--- The form --> <tml:form id="names">
Surname: <tml:input name="surname"/><br/> <button onclick="callAction('<tml:action ref="validateAndSave"/>')">Store</button> In this example a form should be stored by a TML-Action. The action additionally executes some validations, if the fields "firstname" and "surname" are filled. First the action "validateAndSave" is defined, as known from example 1. In the form finally a button is defined with event "onClick" calling the JavaScript function "callAction". As in example 2 the <tml:action>-Tag will generate the string parameter for this function. But different than there, the action is not defined "in place", but the predefined action "validateAndSave" is referenced via ref-Attribute. Easier to use, but less customizable, functionalities for invoking actions when select field changes values or clicking a button are provided via the followingWebTML-Tags and Attributes <tml:input type="select" changeaction="actionid"/> <tml:button clickaction="actionid"/> |
Syndicate
Dokumentationen
© Innovation Gate
|
|||||||||||||