View Javadoc

1   package pl.caltha.forms.internal.ui;
2   
3   import org.xml.sax.Attributes;
4   
5   import pl.caltha.forms.ConstructionException;
6   import pl.caltha.forms.internal.model.InstanceImpl;
7   import pl.caltha.forms.internal.util.Util;
8   
9   /***
10   * Formatted control implementation. Includes:
11   * <ul>
12   *      <li><code>input</code></li>
13   *      <li><code>textarea</code></li>
14   *      <li><code>secret</code></li>
15   *      <li><code>output</code></li>
16   * </ul>
17   *
18   * @author <a href="mailto:zwierzem@ngo.pl">Damian Gajda</a>
19   * @version $Id: NodeControlFormatted.java,v 1.2 2005/06/24 10:33:07 zwierzem Exp $
20   */
21  public class NodeControlFormatted extends NodeControl
22  {
23      private int maxLength;
24  
25      public NodeControlFormatted(String type, Attributes atts)
26      throws ConstructionException
27      {
28          super(type, atts);
29  
30          format = Util.getSAXAttributeVal(atts, "format");
31          if(format != null)
32          {
33              //TODO: build a format depending on its form and field datatype.
34              // SimpleDateFormat
35              // DecimalFormat
36              // MessageFormat ??
37              //
38          }
39          maxLength = Util.createIntAttribute(atts, "maxLength", -1);
40      }
41  
42      private String format;
43  
44      //------------------------------------------------------------------------
45      // Control methods
46      //
47      public Object getValue(InstanceImpl instance)
48      {
49          Object value = super.getValue(instance);
50  		//if(value != null && value instanceof String && ((String)value).length() > 0)
51  		//{
52  			//TODO: use a format
53  		//}
54          return value;
55      }
56  
57      /***
58       * @return Returns the maxLength.
59       */
60      public int getMaxLength()
61      {
62          return maxLength;
63      }
64  }