1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package net.wotonomy.web; |
20 |
|
|
21 |
|
import net.wotonomy.foundation.NSArray; |
22 |
|
import net.wotonomy.foundation.NSDictionary; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
0 |
public class WOGenericElement extends WODynamicElement { |
33 |
|
|
34 |
0 |
static NSArray bindings = new NSArray( new Object[] |
35 |
0 |
{ "elementName", "omitTags", "elementID", "otherTagString", |
36 |
0 |
"formValue", "formValues", "invokeAction" } ); |
37 |
|
|
38 |
|
public WOGenericElement() { |
39 |
0 |
super(); |
40 |
0 |
} |
41 |
|
|
42 |
|
public WOGenericElement(String n, NSDictionary m, WOElement t) { |
43 |
0 |
super(n, m, t); |
44 |
0 |
} |
45 |
|
|
46 |
|
public String elementName(WOContext c) { |
47 |
0 |
String x = (String)valueForProperty("elementName", c.component()); |
48 |
0 |
if (x != null) |
49 |
0 |
return x; |
50 |
0 |
return c.elementID(); |
51 |
|
} |
52 |
|
|
53 |
|
public void takeValuesFromRequest(WORequest r, WOContext c) { |
54 |
0 |
if ( c.elementID().equals( c.senderID() ) ) |
55 |
|
{ |
56 |
|
Object value; |
57 |
0 |
value = r.formValueForKey( c.elementID() ); |
58 |
0 |
setValueForProperty( "formValue", value, c.component() ); |
59 |
0 |
value = r.formValuesForKey( c.elementID() ); |
60 |
0 |
setValueForProperty( "formValues", value, c.component() ); |
61 |
|
} |
62 |
0 |
} |
63 |
|
|
64 |
|
public WOActionResults invokeAction(WORequest r, WOContext c) |
65 |
|
{ |
66 |
0 |
WOActionResults result = null; |
67 |
0 |
String action = stringForProperty( "invokeAction", c.component() ); |
68 |
0 |
if ( action != null && c.elementID().equals( c.senderID() ) ) |
69 |
|
{ |
70 |
0 |
result = c.component().performAction( action ); |
71 |
|
} |
72 |
0 |
return result; |
73 |
|
} |
74 |
|
|
75 |
|
public void appendToResponse(WOResponse r, WOContext c) { |
76 |
0 |
WOComponent component = c.component(); |
77 |
0 |
if ( !booleanForProperty( "omitTags", component ) ) |
78 |
|
{ |
79 |
0 |
r.appendContentString("<"); |
80 |
0 |
r.appendContentString(elementName(c)); |
81 |
0 |
String other = stringForProperty( "otherTagString", component ); |
82 |
0 |
if ( other != null ) |
83 |
|
{ |
84 |
0 |
r.appendContentString( " " ); |
85 |
0 |
r.appendContentString( other ); |
86 |
|
} |
87 |
0 |
String add = additionalHTMLProperties(component, bindings); |
88 |
0 |
if (add.length() > 0) |
89 |
0 |
r.appendContentString(add); |
90 |
0 |
r.appendContentString(">"); |
91 |
|
} |
92 |
0 |
setValueForProperty( "elementID", c.elementID(), component ); |
93 |
0 |
} |
94 |
|
|
95 |
|
} |