MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Manual do Utilizador Página 10

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 44
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 9
10 CHAPTER 30 Extending ColdFusion with CFX
For instance, the tag can be called as shown in the following code snippet. The resulting message
will incorporate the words
Belinda and 19, just as you would expect (Figure 30.1):
<CFX_HelloWorld
NAME=”Belinda”
AGE=”19”>
Of course, you can provide dynamic expressions to the tag’s attributes, just like any native CFML
tag. For instance, you could supply values from the
SESSION and FORM scopes like so:
<CFX_HelloWorld
NAME=”#SESSION.FirstName#
AGE=”#FORM.Age#”>
If a ColdFusion page tries to call the tag without supplying the NAME or AGE attributes, an exception
will be thrown, resulting in a standard error message (Figure 30.2).
Understanding the Java Code
Even though it’s a very simple example, I’d like to spend a few moments going over a few key ele-
ments of the
<CFX_HelloWorld> source code. For starters, take another look at the first few lines of
the example (Listing 30.1); these are the lines that make it possible for ColdFusion to treat the class
as a CFX tag.
Figure 30.2
An error message is
displayed if required
attributes are not
provided.
Figure 30.1
The <CFX_
HelloWorld>
tag
accepts two attributes
and displays their
values in a simple text
message.
Vista de página 9
1 2 ... 5 6 7 8 9 10 11 12 13 14 15 ... 43 44

Comentários a estes Manuais

Sem comentários