|
|||||||||||||||||||
Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Form.java | 0% | 0% | 0% | 0% |
|
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 | 0 |
public void setDefaultButton(ActionSource defaultButton) |
28 |
{ |
|
29 | 0 |
this.defaultButton = defaultButton; |
30 |
} |
|
31 |
|
|
32 | 0 |
public void render(RenderContext context) throws IOException |
33 |
{ |
|
34 | 0 |
if (isVisible()) |
35 |
{ |
|
36 | 0 |
context.startTag("FORM action=\"" + context.getRequestPath() + "\" id=\"" + uniqueId(context) + "\""); |
37 | 0 |
if (defaultButton != null) |
38 |
{ |
|
39 | 0 |
context.emptyTag("INPUT type=\"hidden\" name=\"" + uniqueId(context) + "\" value=\"action\""); |
40 | 0 |
context.registerParsingComponent(this); |
41 |
} |
|
42 | 0 |
renderChildren(context); |
43 | 0 |
context.endTag("FORM"); |
44 |
} |
|
45 |
} |
|
46 |
|
|
47 | 0 |
public void parse(RenderContext context) |
48 |
{ |
|
49 | 0 |
super.parse(context); |
50 | 0 |
if ("action".equals(context.getRequestParameter(getId()))) |
51 |
{ |
|
52 | 0 |
defaultButton.signalActionEvent(); |
53 |
} |
|
54 |
} |
|
55 |
} |
|
56 |
|
|