01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.html;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import com.javelin.swinglets.*;
12: import com.javelin.swinglets.plaf.*;
13: import com.javelin.swinglets.event.*;
14:
15: /**
16: * HTMLFormUI defines a look and feel for default HTML.
17: *
18: * @author Robin Sharp
19: */
20:
21: public class HTMLFormUI extends HTMLContainerUI {
22: /**
23: * Render the UI on the PrintWriter
24: */
25: public void updateComponentHeader(PrintWriter out, SComponent c) {
26: if (!c.isVisible())
27: return;
28:
29: SForm form = (SForm) c;
30:
31: out.print("<FORM");
32:
33: HTMLUtility.setName(out, form);
34:
35: out.print(" METHOD=\"");
36: out.print(form.getMethod());
37: out.print("\" ");
38:
39: //out.print( " ENCTYPE = \"multipart/form-data\"" );
40:
41: if (form.getAction() != null) {
42: out.print(" ACTION=\"");
43: out.print(form.getAction().getUrl());
44: out.print("\"");
45:
46: if (form.getAction().getTarget() != null) {
47: if (form.getAction().getTarget().equals(SFrame.NEW))
48: out.print(" target=\"_blank\"");
49: else if (form.getAction().getTarget().equals(
50: SFrame.SELF))
51: out.print(" target=\"_self\"");
52: else if (form.getAction().getTarget().equals(
53: SFrame.PARENT))
54: out.print(" target=\"_parent\"");
55: else if (form.getAction().getTarget()
56: .equals(SFrame.TOP))
57: out.print(" target=\"_top\"");
58: else {
59: out.print(" target=\"");
60: out.print(form.getAction().getTarget());
61: out.print("\"");
62: }
63: }
64: } else {
65: //By default - write back to myself
66: out.print(" ACTION=\"");
67: out.print(form.getComponentUrl());
68: out.print("\"");
69: }
70:
71: updateEvent(out, c);
72:
73: out.println(" >");
74:
75: }
76:
77: /**
78: * Render the UI on the PrintWriter
79: */
80: public void updateComponentFooter(PrintWriter out, SComponent c) {
81: if (!c.isVisible())
82: return;
83:
84: //WRITE OUT THE FRAME AND COMPONENT AS HIDDEN FIELDS
85: //HTMLUtility.setFrameName( out, c );
86: //HTMLUtility.setComponentName( out, c );
87:
88: out.print("</FORM>");
89: }
90:
91: }
|