summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
commit40a9d99496e098562f090fb7ffce9e749011b131 (patch)
tree437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java
parentff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff)
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java')
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java181
1 files changed, 89 insertions, 92 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java
index 887d1a3..b4dca91 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOForm.java
@@ -21,104 +21,101 @@ package net.wotonomy.web;
import net.wotonomy.foundation.NSArray;
import net.wotonomy.foundation.NSDictionary;
-/**
-* Implements a FORM element with dynamic bindings.
-* @author michael@mpowers.net
-* @author $Author: cgruber $
-* @version $Revision: 905 $
-*/
+/**
+ * Implements a FORM element with dynamic bindings.
+ *
+ * @author michael@mpowers.net
+ * @author $Author: cgruber $
+ * @version $Revision: 905 $
+ */
public class WOForm extends WODynamicElement {
- public WOForm() {
- super();
- }
-
- public WOForm(String n, NSDictionary m, WOElement t) {
- super(n, m, t);
- }
-
- public String href(WOContext c) {
- return (String)valueForProperty("href", c.component());
- }
-
- public String directActionName(WOContext c) {
- return (String)valueForProperty("directAction", c.component());
- }
-
- public String directActionClass(WOContext c) {
- return (String)valueForProperty("actionClass", c.component());
- }
-
- public boolean multipleSubmit(WOContext c) {
- return booleanForProperty("multipleSubmit", c.component());
- }
-
- public void takeValuesFromRequest (
- WORequest aRequest, WOContext aContext)
- {
- if ( rootElement != null )
- {
- rootElement.takeValuesFromRequest( aRequest, aContext );
- }
- }
-
- public void appendToResponse(WOResponse r, WOContext c) {
- //Append the opening tag
- r.appendContentString("<FORM");
- String link = href(c);
- //Append the href, if present
- if (link != null) {
- r.appendContentString(" HREF=\"");
- r.appendContentString(link);
- r.appendContentString("\"");
- link = null;
- } else {
- link = directActionName(c);
- }
-
- //otherwise, append Direct Action
- if (link != null) {
- r.appendContentString(" HREF=\"");
- if (directActionClass(c) != null)
- link = directActionClass(c) + "/" + link;
- r.appendContentString(c.directActionURLForActionNamed(link, urlFields(c.component())));
- r.appendContentString("\"");
- link = null;
+ public WOForm() {
+ super();
+ }
+
+ public WOForm(String n, NSDictionary m, WOElement t) {
+ super(n, m, t);
+ }
+
+ public String href(WOContext c) {
+ return (String) valueForProperty("href", c.component());
+ }
+
+ public String directActionName(WOContext c) {
+ return (String) valueForProperty("directAction", c.component());
+ }
+
+ public String directActionClass(WOContext c) {
+ return (String) valueForProperty("actionClass", c.component());
+ }
+
+ public boolean multipleSubmit(WOContext c) {
+ return booleanForProperty("multipleSubmit", c.component());
+ }
+
+ public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) {
+ if (rootElement != null) {
+ rootElement.takeValuesFromRequest(aRequest, aContext);
+ }
+ }
+
+ public void appendToResponse(WOResponse r, WOContext c) {
+ // Append the opening tag
+ r.appendContentString("<FORM");
+ String link = href(c);
+ // Append the href, if present
+ if (link != null) {
+ r.appendContentString(" HREF=\"");
+ r.appendContentString(link);
+ r.appendContentString("\"");
+ link = null;
+ } else {
+ link = directActionName(c);
+ }
+
+ // otherwise, append Direct Action
+ if (link != null) {
+ r.appendContentString(" HREF=\"");
+ if (directActionClass(c) != null)
+ link = directActionClass(c) + "/" + link;
+ r.appendContentString(c.directActionURLForActionNamed(link, urlFields(c.component())));
+ r.appendContentString("\"");
+ link = null;
// } else if (associations.objectForKey("action") != null) {
- } else {
- //finally, append action
- r.appendContentString(" action=\"");
- r.appendContentString(c.componentActionURL());
- r.appendContentString("\"");
- } //else
+ } else {
+ // finally, append action
+ r.appendContentString(" action=\"");
+ r.appendContentString(c.componentActionURL());
+ r.appendContentString("\"");
+ } // else
// now defaulting to action if not specified(?): WOBuilder does generate WOForms without any bindings(!)
// throw new IllegalArgumentException("You must use one of directActionName, action, or href.");
- //Append any additional properties
- link = additionalHTMLProperties(c.component(), new NSArray(new Object[]{
- "href", "action", "directActionName", "actionClass", "multipleSubmit" }));
- if (link.length() > 0)
- r.appendContentString(link);
- r.appendContentString(">");
- //Notify that we're inside a form now
- c.setInForm(true);
- //Append the inner template
- rootElement.appendToResponse(r, c);
- //Close the tag
- r.appendContentString("</FORM>");
+ // Append any additional properties
+ link = additionalHTMLProperties(c.component(),
+ new NSArray(new Object[] { "href", "action", "directActionName", "actionClass", "multipleSubmit" }));
+ if (link.length() > 0)
+ r.appendContentString(link);
+ r.appendContentString(">");
+ // Notify that we're inside a form now
+ c.setInForm(true);
+ // Append the inner template
+ rootElement.appendToResponse(r, c);
+ // Close the tag
+ r.appendContentString("</FORM>");
// c.deleteLastElementIDComponent();
- c.setInForm(false);
- }
-
- public WOActionResults invokeAction(WORequest r, WOContext c) {
- //We only process the request if it's not a multipleSubmit (otherwise we leave it to the buttons)
- if (!multipleSubmit(c)
- && c.elementID().equals(c.senderID())
- && associations.objectForKey("action") != null ) {
- return (WOActionResults)valueForProperty("action", c.component());
- }
- WOActionResults res = rootElement.invokeAction(r, c);
- return res;
- }
+ c.setInForm(false);
+ }
+
+ public WOActionResults invokeAction(WORequest r, WOContext c) {
+ // We only process the request if it's not a multipleSubmit (otherwise we leave
+ // it to the buttons)
+ if (!multipleSubmit(c) && c.elementID().equals(c.senderID()) && associations.objectForKey("action") != null) {
+ return (WOActionResults) valueForProperty("action", c.component());
+ }
+ WOActionResults res = rootElement.invokeAction(r, c);
+ return res;
+ }
}