01: package com.javelin.swinglets.plaf.wml;
02:
03: import com.javelin.swinglets.*;
04:
05: import java.io.*;
06:
07: public class WMLUtility //These need to be put into WMLComponentUI
08: {
09: public synchronized static void setFrameName(PrintWriter out,
10: SComponent component) {
11: // Note - WML does not have a HIDDEN input type (only TEXT|PASSWORD). Need to find
12: // an alternative.
13: out.print("<input type=\"HIDDEN\"");
14: out.print(" name=\"");
15: out.print(SConstants.SOURCE_CONTAINER);
16: out.print("\" value=\"");
17: out.print(component.getTopLevelAncestor().getName());
18: out.println("\" >");
19: }
20:
21: public synchronized static void setComponentName(PrintWriter out,
22: SComponent component) {
23: // Note - WML does not have a HIDDEN input type (only TEXT|PASSWORD). Need to find
24: // an alternative.
25: out.print("<input type=\"HIDDEN\"");
26: out.print(" name=\"");
27: out.print(SConstants.SOURCE_COMPONENT);
28: out.print("\" value=\"");
29: out.print(component.getName());
30: out.println("\" >");
31: }
32:
33: public synchronized static void setName(PrintWriter out,
34: SComponent c) {
35: if (c.getName() != null)
36: setTag(out, "name", c.getName());
37: }
38:
39: public synchronized static void setTitle(PrintWriter out,
40: SComponent c) {
41: if (c.getName() != null)
42: setTag(out, "title", c.getName()); // where can I get title from?
43: }
44:
45: public synchronized static void setSrc(PrintWriter out, SIcon c) {
46: if (c.getUrl() != null)
47: setTag(out, "src", c.getUrl());
48: }
49:
50: public synchronized static void setTag(PrintWriter out,
51: String tagname, int tagvalue) {
52: out.print(" ");
53: out.print(tagname);
54: out.print("=\"");
55: out.print(tagvalue);
56: out.print("\" ");
57: }
58:
59: public synchronized static void setTag(PrintWriter out,
60: String tagname, String tagvalue) {
61: if (tagvalue == null)
62: return;
63:
64: out.print(" ");
65: out.print(tagname);
66: out.print("=\"");
67: out.print(tagvalue);
68: out.print("\" ");
69: }
70:
71: public static String encodeURL(SComponent component, String url) {
72: SwingletManager sm = component.getSwingletManager();
73:
74: if (sm instanceof ServletManager
75: && ((ServletManager) sm).getResponse() != null) {
76: return ((ServletManager) sm).getResponse().encodeUrl(url);
77: }
78:
79: return url;
80: }
81: }
|