| 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 |
|
public class WOForm extends WODynamicElement { |
| 31 |
|
|
| 32 |
|
public WOForm() { |
| 33 |
0 |
super(); |
| 34 |
0 |
} |
| 35 |
|
|
| 36 |
|
public WOForm(String n, NSDictionary m, WOElement t) { |
| 37 |
0 |
super(n, m, t); |
| 38 |
0 |
} |
| 39 |
|
|
| 40 |
|
public String href(WOContext c) { |
| 41 |
0 |
return (String)valueForProperty("href", c.component()); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
public String directActionName(WOContext c) { |
| 45 |
0 |
return (String)valueForProperty("directAction", c.component()); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public String directActionClass(WOContext c) { |
| 49 |
0 |
return (String)valueForProperty("actionClass", c.component()); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public boolean multipleSubmit(WOContext c) { |
| 53 |
0 |
return booleanForProperty("multipleSubmit", c.component()); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
public void takeValuesFromRequest ( |
| 57 |
|
WORequest aRequest, WOContext aContext) |
| 58 |
|
{ |
| 59 |
0 |
if ( rootElement != null ) |
| 60 |
|
{ |
| 61 |
0 |
rootElement.takeValuesFromRequest( aRequest, aContext ); |
| 62 |
|
} |
| 63 |
0 |
} |
| 64 |
|
|
| 65 |
|
public void appendToResponse(WOResponse r, WOContext c) { |
| 66 |
|
|
| 67 |
0 |
r.appendContentString("<FORM"); |
| 68 |
0 |
String link = href(c); |
| 69 |
|
|
| 70 |
0 |
if (link != null) { |
| 71 |
0 |
r.appendContentString(" HREF=\""); |
| 72 |
0 |
r.appendContentString(link); |
| 73 |
0 |
r.appendContentString("\""); |
| 74 |
0 |
link = null; |
| 75 |
0 |
} else { |
| 76 |
0 |
link = directActionName(c); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
|
| 80 |
0 |
if (link != null) { |
| 81 |
0 |
r.appendContentString(" HREF=\""); |
| 82 |
0 |
if (directActionClass(c) != null) |
| 83 |
0 |
link = directActionClass(c) + "/" + link; |
| 84 |
0 |
r.appendContentString(c.directActionURLForActionNamed(link, urlFields(c.component()))); |
| 85 |
0 |
r.appendContentString("\""); |
| 86 |
0 |
link = null; |
| 87 |
|
|
| 88 |
0 |
} else { |
| 89 |
|
|
| 90 |
0 |
r.appendContentString(" action=\""); |
| 91 |
0 |
r.appendContentString(c.componentActionURL()); |
| 92 |
0 |
r.appendContentString("\""); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
0 |
link = additionalHTMLProperties(c.component(), new NSArray(new Object[]{ |
| 99 |
0 |
"href", "action", "directActionName", "actionClass", "multipleSubmit" })); |
| 100 |
0 |
if (link.length() > 0) |
| 101 |
0 |
r.appendContentString(link); |
| 102 |
0 |
r.appendContentString(">"); |
| 103 |
|
|
| 104 |
0 |
c.setInForm(true); |
| 105 |
|
|
| 106 |
0 |
rootElement.appendToResponse(r, c); |
| 107 |
|
|
| 108 |
0 |
r.appendContentString("</FORM>"); |
| 109 |
|
|
| 110 |
0 |
c.setInForm(false); |
| 111 |
0 |
} |
| 112 |
|
|
| 113 |
|
public WOActionResults invokeAction(WORequest r, WOContext c) { |
| 114 |
|
|
| 115 |
0 |
if (!multipleSubmit(c) |
| 116 |
0 |
&& c.elementID().equals(c.senderID()) |
| 117 |
0 |
&& associations.objectForKey("action") != null ) { |
| 118 |
0 |
return (WOActionResults)valueForProperty("action", c.component()); |
| 119 |
|
} |
| 120 |
0 |
WOActionResults res = rootElement.invokeAction(r, c); |
| 121 |
0 |
return res; |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
} |