1<!---
2Copyright 2006-2007 TeraTech, Inc. http://teratech.com/
3 4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7 8http://www.apache.org/licenses/LICENSE-2.0
9 10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15--->
16<cfscript>
17 if (fb_.verbInfo.executionMode is "start") {
18 // validate attributes
19 // <parameter> is actually two verbs and behaves differently depending on its
20 // parent:
21 // - inside an <include>, it saves / sets variables for the duration of the
22 // include just as it does inside a <do> directive
23 // - inside an <xfa>, it defines URL parameters to add to the XFA value
24 if (structKeyExists(fb_.verbInfo,"parent")) {
25 26 if (fb_.verbInfo.parent.lexiconVerb is "include") {
27 28 // name - string - required, must be varname or varname.varname
29 if (not structKeyExists(fb_.verbInfo.attributes,"name")) {
30 fb_throw("fusebox.badGrammar.requiredAttributeMissing",
31 "Required attribute is missing",
32 "The attribute 'name' is required, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
33 }
34 fb_.match1 = REFind("[A-Za-z0-9_]*",fb_.verbInfo.attributes.name,1,true);
35 fb_.match2 = REFind("[A-Za-z0-9_]*\.[A-Za-z0-9_]*",fb_.verbInfo.attributes.name,1,true);
36 fb_.nameLen = len(fb_.verbInfo.attributes.name);
37 if (fb_.match1.pos[1] eq 1 and fb_.match1.len[1] eq fb_.nameLen) {
38 fb_.name = "variables." & fb_.verbInfo.attributes.name;
39 } else if (fb_.match2.pos[1] eq 1 and fb_.match2.len[1] eq fb_.nameLen) {
40 fb_.name = fb_.verbInfo.attributes.name;
41 } else {
42 fb_throw("fusebox.badGrammar.invalidAttributeValue",
43 "Attribute has invalid value",
44 "The attribute 'name' must be a simple variable name, optionally qualified by a scope name, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
45 }
46 // value - string - optional
47 // strict mode - check attribute count:
48 if (fb_.verbInfo.action.getCircuit().getApplication().strictMode) {
49 if (structCount(fb_.verbInfo.attributes) neq 2) {
50 fb_throw("fusebox.badGrammar.unexpectedAttributes",
51 "Unexpected attributes",
52 "Unexpected attributes were found in a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
53 }
54 }
55 56 // append this parameter to the parent data:
57 arrayAppend(fb_.verbInfo.parent.parameters,fb_.name);
58 // output the push code:
59 fb_appendLine('<' & 'cfif isDefined("#fb_.name#")><' &
60 'cfset myFusebox.stack["#fb_.name#"] = #fb_.name# ></' & 'cfif>');
61 // reset the value of the "local" variable, if appropriate:
62 if (structKeyExists(fb_.verbInfo.attributes,"value")) {
63 fb_appendLine('<' & 'cfset #fb_.name# = "#fb_.verbInfo.attributes.value#" />');
64 }
65 66 } else if (fb_.verbInfo.parent.lexiconVerb is "xfa") {
67 68 // name - string - required
69 if (not structKeyExists(fb_.verbInfo.attributes,"name")) {
70 fb_throw("fusebox.badGrammar.requiredAttributeMissing",
71 "Required attribute is missing",
72 "The attribute 'name' is required, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
73 }
74 // value - string - required
75 if (not structKeyExists(fb_.verbInfo.attributes,"value")) {
76 fb_throw("fusebox.badGrammar.requiredAttributeMissing",
77 "Required attribute is missing",
78 "The attribute 'value' is required, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
79 }
80 fb_.parameter = structNew();
81 fb_.parameter.name = fb_.verbInfo.attributes.name;
82 fb_.parameter.value = fb_.verbInfo.attributes.value;
83 // append this parameter to the parent data:
84 arrayAppend(fb_.verbInfo.parent.parameters,fb_.parameter);
85 86 } else {
87 88 fb_throw("fusebox.badGrammar.parameterInvalidParent",
89 "Verb 'parameter' has invalid parent verb",
90 "Found 'parameter' verb with no valid parent verb (either 'include' or 'xfa') in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
91 92 }
93 94 } else {
95 96 fb_throw("fusebox.badGrammar.parameterInvalidParent",
97 "Verb 'parameter' has invalid parent verb",
98 "Found 'parameter' verb with no valid parent verb (either 'include' or 'xfa') in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
99 100 }
101 102 }
103</cfscript>