1
2 package net.wotonomy.web;
3
4 import net.wotonomy.foundation.NSArray;
5 import net.wotonomy.foundation.NSDictionary;
6
7 /***
8 * WOImageButton renders a dynamically generated IMG tag or an INPUT tag, depending on whether the
9 * element is inside a WOForm (in which case an INPUT of type IMAGE is generated) or not (in which
10 * case the equivalent of a WOActiveImage)
11 *
12 * Bindings are:
13 * <UL>
14 * <LI>src: A static URL for the image source.</li>
15 * <li>data: A NSData object with the image content. Must be used with mimeType.</li>
16 * <li>mimeType: The MIME type for the image data. Can be used with filename or data bindings.</li>
17 * <li>filename: The path to a file containing an image.</li>
18 * <li>framework: The framework where the image should be retrieved from (used in conjunction with filename).</li>
19 *
20 * @author ezamudio@nasoft.com
21 * @author $Author: cgruber $
22 * @version $Revision: 905 $
23 */
24 public class WOImageButton extends WOImage {
25
26 protected WOImageButton() {
27 super();
28 }
29
30 public WOImageButton(String aName, NSDictionary aMap, WOElement template) {
31 super(aName, aMap, template);
32 }
33
34 public String buttonName(WOContext c) {
35 String x = (String)valueForProperty("name", c.component());
36 if (x != null)
37 return x;
38 return c.elementID();
39 }
40
41 public void appendToResponse(WOResponse r, WOContext c) {
42 if (c.isInForm()) {
43
44 r.appendContentString("<INPUT TYPE=IMAGE NAME=\"");
45 r.appendContentString(buttonName(c));
46 r.appendContentString("\" SRC=\"");
47 r.appendContentString(sourceURL(c));
48 r.appendContentString("\"");
49 r.appendContentString(additionalHTMLProperties(c.component(), new NSArray(new Object[]{
50 "name", "action", "src", "filename", "framework", "data", "mimeType" })));
51 r.appendContentString(">");
52 } else {
53
54 new WOActiveImage(name, associations, rootElement).appendToResponse(r, c);
55 }
56 }
57
58 }