1 /*
2 * Angkor Web Framework
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7 package com.tirsen.angkor.widget;
8
9 import com.tirsen.angkor.RenderContext;
10 import com.tirsen.angkor.event.ActionSource;
11
12 import java.io.IOException;
13
14 /***
15 * A form. Sends an action event when it is has been submitted regardless wheather any button was pressed.
16 *
17 * <!-- $Id: Form.java,v 1.4 2002/10/09 21:37:37 tirsen Exp $ -->
18 * <!-- $Author: tirsen $ -->
19 *
20 * @author Jon Tirsén (tirsen@users.sourceforge.net)
21 * @version $Revision: 1.4 $
22 */
23 public class Form extends Container
24 {
25 private ActionSource defaultButton;
26
27 public void setDefaultButton(ActionSource defaultButton)
28 {
29 this.defaultButton = defaultButton;
30 }
31
32 public void render(RenderContext context) throws IOException
33 {
34 if (isVisible())
35 {
36 context.startTag("FORM action=\"" + context.getRequestPath() + "\" id=\"" + uniqueId(context) + "\"");
37 if (defaultButton != null)
38 {
39 context.emptyTag("INPUT type=\"hidden\" name=\"" + uniqueId(context) + "\" value=\"action\"");
40 context.registerParsingComponent(this);
41 }
42 renderChildren(context);
43 context.endTag("FORM");
44 }
45 }
46
47 public void parse(RenderContext context)
48 {
49 super.parse(context);
50 if ("action".equals(context.getRequestParameter(getId())))
51 {
52 defaultButton.signalActionEvent();
53 }
54 }
55 }
This page was automatically generated by Maven