KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > text > SDefaultFormatter


1 /*
2  * SDefaultFormatter.java
3  *
4  * Created on 9. September 2003, 14:16
5  */

6
7 /*
8  * $Id: SDefaultFormatter.java,v 1.4 2005/02/03 13:50:35 hengels Exp $
9  * Copyright 2000,2005 wingS development team.
10  *
11  * This file is part of wingS (http://www.j-wings.org).
12  *
13  * wingS is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License
15  * as published by the Free Software Foundation; either version 2.1
16  * of the License, or (at your option) any later version.
17  *
18  * Please see COPYING for the complete licence.
19  */

20 package org.wings.text;
21
22 import org.wings.SFormattedTextField;
23 import org.wings.script.JavaScriptListener;
24
25 /**
26  * SDefault Formatter simulates the normal behavior of a TextField.
27  * (when an ActionListener is added, the Form will be submitted onchange)
28  *
29  * @author theresia
30  */

31 public class SDefaultFormatter
32         extends SAbstractFormatter
33 {
34     /**
35      * Creates a new instance of SDefaultFormatter
36      */

37     public SDefaultFormatter() {
38     }
39
40     public Object JavaDoc stringToValue(String JavaDoc text) {
41         return text;
42     }
43
44     public String JavaDoc valueToString(Object JavaDoc value) {
45         return "";
46     }
47
48     /*
49      * Creates the javaScriptFunction based on the given Format. Here isn't any
50      * Format, so the SDefaultFormatter creates the code an ActionListener needs.
51      */

52     public JavaScriptListener generateJavaScript(SFormattedTextField field, boolean actionListener) {
53         if (actionListener) {
54             JavaScriptListener javaScriptListener = new JavaScriptListener("onchange", "submit()");
55             return javaScriptListener;
56         } else {
57             return new JavaScriptListener("", "");
58         }
59     }
60 }
61
Popular Tags