Event

 

WML包含有許多元素可以讓你去處理領航還有一些user agent event 而你可以用do onevent 來達成。

 

do element

  • Description

    Do 的元素讓使用者有一般的方法來實行一些行為在目前的card上,是一個card-level 的使用者介面元素。Do 元素被映對到一個唯一的user interface widget user可以使它activate. widget mapping可能是一個button 或是function call 或者是聲控的裝置。這個attribute是用來指示user agent WML的作者想要如何使用這些元素 ,而且它讓user agent 可以提供適當的映對到實體的user Interface 的結構。Do 元素可能出現在card-leveldeck-level:

    Card-level: do 元素可能出現在card 的任何地方。假如user agent 想要在文件中表達do 元素,它就要用element’s anchor point 當作表達 point anywhere in the text

    Deck-level:  do element 可能出現在template,表現依各 deck-level

    do element.  deck-level do element可以用在所有deck中的card,它就等於在每一張card 上定義一樣

    下面是你要特別注意的地方:

    假如card-leveldeck-level有同樣名字的那card-leveloverrides

    inactive do elements active do elements noop task element

    不會顯現給user.

    user 可以存取所有沒有nooptask do elements. user

     activate 這些user interface items 那相關的do element 就會activate

  • Contained elements

    go|prev|noop|refresh

  • Syntax

    下表是 Do element 的屬性

    Attribute Explanation
    type=cdata The do element type. This attribute provides an indication to the user agent about how the WML author intended the element to be used, and how it should be mapped to a physical user interface construction. All types are reserved, except for those marked as experimental.

    This attribute is required. User agents accept any type, but may treat any unrecognized type as the equivalent of unknown.

    In the following, the * character represents any string. For example, Test * indicates any string starting with the word Test.

    accept Positive acknowledgement (acceptance).
    prev Navigates backwards through history.
    help Request for help. May be context-sensitive.
    reset Clearing or resetting state.
    options Context-sensitive request for options or additional operations.
    delete Delete item or choice.
    unknown A generic do element. Equivalent to an empty string, e.g., type="".
    X-*, x-* Experimental types. This set is not reserved.
    vnd.*, VND.* and any combination of [Vv] [Nn] [Dd] .* Vendor-specific or user-agent- specific types. This set is not reserved. Vendors should allocate names with the format VND.CO-TYPE, where CO is a company name abbreviation and type is the do element.

    label=vdata This attribute specifies a textual string for labeling the user interface widget. If an element cannot be dynamically labeled, this attribute is ignored. To work well, labels should have no more than six characters.
    name=nmtoken This attribute specifies the name of the do event binding. If two do elements are specified with the same name, they refer to the same binding. If do elements are specified both at the card-level (in a card) and at the deck-level (in a template) and both elements have the same name, the deck- level do element is ignored. It is a WML syntax error to specify two or more do elements with the same name in a single card or in the template. A name with an empty value is equivalent to an unspecified name attribute. An unspecified name defaults to the value of the type attribute.
    optional=boolean If you set this attribute to true, the user agent may ignore this element. The default is false.
    xml:lang See "Common attributes" on page 23.
    id See "Common attributes" on page 23.
    class See "Common attributes" on page 23.

    Example [22.]

    下面的例子示範do element包含有一個go的task

     當user 選擇next user agent就會到card2然後顯現給user

    <card id="card1">

    <do type="accept" label="Next">

    <go href="#card2"/>

    </do>

    <p>

    Select <b> Next </b> to go to the next card.

    </p>

    </card>

    <card id="card2">

    <p>

    This is card 2.

    </p>

    ontimer Event

  • Description

    ontimer event 可以被定義在下面的elements:

    card

    template

    timer展開event就會發生

  • Syntax

    下表是  ontimer event 的屬性

    Attribute Explanation
    ontimer=href Specifies an intrinsic event that instructs the user agent to go to the specified URI after the timer has expired.
    IdSee "Common attributes" on page 23.
    classSee "Common attributes" on page 23.

    Example [23.]

    下面是簡單的例子

    <card id="cardname" ontimer="http://wapserver/hello.wml" title="title">

    <timer value="50"/>

    <p>

    Hello World!

    </p>

    </card>

    onenterforward Event
    Attribute Explanation
    onenterforward=href Specifies an intrinsic event that instructs the user agent to go to the specified URI when the user enters this card.
    id See "Common attributes" on page 23.
    ClassSee "Common attributes" on page 23.

    Example [24.]

    當一個內部的event發生,你可以定義兩種方法來執行。

    <card onenterforward="http://wapserver/hello.wml"> Hello World! You came

    back </card>

    或是

    <card>

    <onevent type="onenterforward">

    <go href=" http://wapserver/hello.wml "/>

    </onevent>

    <p>

    Hello World! You came back.

    </p>

    </card>

    onenterbackward Event
    Attribute Explanation
    onenterbackward=href Specifies an intrinsic event that instructs the user agent to go to the specified URI when the user navigates backwards to this card, for example, using a prev task.
    id See "Common attributes" on page 23.
    class See "Common attributes" on page 23.

    Example [25.]

    <card id="card1">

    <onevent type="onenterbackward">

    <go href="#card2"/>

    </onevent>

    <p>

    Hello World!

    </p>

    </card>

    <card id="card2">

    <p>

    You came back!

    </p>

    </card>

    onpick Event
    Attribute Explanation
    onpick=href Specifies an intrinsic event that instructs the user agent to go to the specified URI when the user selects the option (or deselects it if the select element allows multiple choices) in which the event is specified.
    id See "Common attributes" on page 23.
    class See "Common attributes" on page 23.

    Example [26.]

    <card id="Card_1">

    <p>

    Select your favorite animal:

    <select name="animal">

    <option value="1" onpick="cat.wml"> Cat </option>

    <option value="2" onpick="dog.wml"> Dog </option>

    <option value="3" onpick="horse.wml"> Horse </option>

    </select>

    </p>

    </card>

    onevent element
    Attribute Explanation
    type=CDATA The type attribute indicates the name of the intrinsic event.

    This attribute is required.

    id See "Common attributes" on page 23.
    class See "Common attributes" on page 23.

    Example [27.]

    <card>

    <onenvent type="onenterbackward">

    <go href="http://www.acme.com/foo.wml"/>

    </onevent>

    <p>

    Welcome to a new age!

    </p>

    </card>

    postfield element
    Attribute Explanation
    name=vdata The name attribute specifies the field name.

    This attribute is required.

    value=vdata The value attribute specifies the field value.

    This attribute is required.

    idSee "Common attributes" on page 23.
    class See "Common attributes" on page 23.

    Example [28.]

    <go method="post" href="http://hostname/servlet/bank">

    <postfield name="money" value="100"/>

    <postfield name="account" value="12345"/>

    <postfield name="operation" value="deposit"/>

    </go>

    Card and deck intrinsic events

    你可能會用override semantics來定義在card deck level上的intrinsic eventsonenterforward onenterbackward。而deck-level event-handler可以被onenterforward element overridden

    Card and deck task override

    Card-level: event-handling element只會出現在 card裡面,而且定義目前cardevent-processing

    Deck-level: event-handling element 只會出現在template裡面而且定義的event-processing 可以用在這個deck中的所有cards. deck-level event-handling

    Element就好像在這個deck中每一張card定義一樣

    下面是幾個特別需要定義的規則:

    假如card deck具有同樣名字的event card-level event-handling element overrides  deck-level event-handling

    假如card deck具有同樣typeonevent card-level onevent element overrides deck-level onevent element

    假如card deck具有同樣的do element A card-level do element overrides a deck-level do element

    假如card-level element 定義 noop task overrides a deck-level elementdeck會完全忽略它,而且不會造成任何的影響。

    deck-level elements will be ignored and no side

    effects will occur on delivery of the event. In this case, the user agent will not show

    the element to the user, for example, render a UI control. In effect, the noop

    removes the element from the card.

    Override example [29.]

     

    <wml>

    <template>

    <do type="options" name="do1" label="default">

    <prev/>

    </do>

    </template>

    <card id="first">

    <!-- deck-level do not overridden. The card

    exposes the deck-level do as part of the current card. -->

    <!-- rest of the card -->

    ...

    </card>

    <card id="second">

    <!-- deck-level do is overridden with noop.

    It is not exposed to the user. -->

    <do type="options" name="do1">

    <noop/>

    </do>

    <!-- rest of the card -->

    ...

    </card>

    <card id="third">

    <!-- deck-level do is overridden.

    It is replaced by a card-level do -->

    <do type="options" name="do1" label="options">

    <go href="/options"/>

    </do>

    <!-- rest of the card -->

    ...

    </card>

    </wml>