diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-05-19 17:56:33 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-05-19 17:56:33 -0400 |
| commit | aedc34d55462a75e329bbf342251ff6504cd117e (patch) | |
| tree | bcc8f1f2352582717b484df302aeea6696b8f000 /projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java | |
Initial import from SVN
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java')
| -rw-r--r-- | projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java new file mode 100644 index 0000000..7c9f22e --- /dev/null +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOImageButton.java @@ -0,0 +1,58 @@ + +package net.wotonomy.web; + +import net.wotonomy.foundation.NSArray; +import net.wotonomy.foundation.NSDictionary; + +/** + * WOImageButton renders a dynamically generated IMG tag or an INPUT tag, depending on whether the + * element is inside a WOForm (in which case an INPUT of type IMAGE is generated) or not (in which + * case the equivalent of a WOActiveImage) + * + * Bindings are: + * <UL> + * <LI>src: A static URL for the image source.</li> + * <li>data: A NSData object with the image content. Must be used with mimeType.</li> + * <li>mimeType: The MIME type for the image data. Can be used with filename or data bindings.</li> + * <li>filename: The path to a file containing an image.</li> + * <li>framework: The framework where the image should be retrieved from (used in conjunction with filename).</li> + * + * @author ezamudio@nasoft.com + * @author $Author: cgruber $ + * @version $Revision: 905 $ + */ +public class WOImageButton extends WOImage { + + protected WOImageButton() { + super(); + } + + public WOImageButton(String aName, NSDictionary aMap, WOElement template) { + super(aName, aMap, template); + } + + public String buttonName(WOContext c) { + String x = (String)valueForProperty("name", c.component()); + if (x != null) + return x; + return c.elementID(); + } + + public void appendToResponse(WOResponse r, WOContext c) { + if (c.isInForm()) { + //generate an INPUT + r.appendContentString("<INPUT TYPE=IMAGE NAME=\""); + r.appendContentString(buttonName(c)); + r.appendContentString("\" SRC=\""); + r.appendContentString(sourceURL(c)); + r.appendContentString("\""); + r.appendContentString(additionalHTMLProperties(c.component(), new NSArray(new Object[]{ + "name", "action", "src", "filename", "framework", "data", "mimeType" }))); + r.appendContentString(">"); + } else { + //generate a WOActiveImage + new WOActiveImage(name, associations, rootElement).appendToResponse(r, c); + } + } + +} |
