Parameters


ATL Server s stencil processor provides support for parameters for your tags. There s no limit to the number of parameters you can give to a single method, and there s no restriction as to how you use them.

The syntax is based on C++ syntax and therefore should be quite straightforward:

 {{simpleString(HelloWorld)}}  {{complexString( Hello, World,!)}} 

You ll notice that these parameters are static (they can t be modified at runtime from user input, for example [2] ). ATL Server supports only static parameters simply because this feature isn t designed to encourage application logic in the SRF file ”it s primarily a layout/design/reusability tool.

For example, in the preceding example you might have a simpleString() method that has a set of built-in parameters that it recognizes and associates with a fixed output string (in this case it might spit out Hello World! ). In the complexString() method you may take a number of parameters. Each of these parameters might represent a string that you want the method to spit into the stream; therefore, this would result in Hello World!

Note that because the simpleString() method takes a number of known parameters and basically looks for a match for which string to show, it s much simpler to implement than the complexString() method, which takes a variable number of arguments and then needs to convert these arguments into individual strings, concatenate these strings into a single larger string, and finally spit this into the HTML stream.

Static parameters are very useful for aiding code reuse because they make functions more generic. For example, say you have {{Hello(1)}} , {{Hello(2)}} , and {{Hello(3)}} . Each of these would call the Hello() method, but the result might vary based on which static parameter you gave it. For example, you might have

 {{Hello(1)}} = "Hello"  {{Hello(2)}} = "Bonjour" 

and

 {{Hello(3)}} = "Guten Tag" 
Note  

The parameters don t have to be numbers . They could easily be strings. For example, you could use {{Hello(English)}} , {{Hello(French}} , and {{Hello(German)}} instead.

[2] The claim that parameters can t be modified at runtime isn t strictly true. It s possible to have methods in one SRF file and make changes to another SRF file (including changes to parameters). You could even have an SRF file change itself and force a refresh. However, this is a clumsy solution and usually indicates either badly structured SRF files or an attempt to move application logic into the SRF file.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net