01: /* TextBoxFactory.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: May 15, 2007 3:15:54 PM, Created by henrichen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zkmob.factory;
20:
21: import javax.microedition.lcdui.TextBox;
22:
23: import org.xml.sax.Attributes;
24: import org.zkoss.zkmob.ZkComponent;
25: import org.zkoss.zkmob.ui.ZkTextBox;
26:
27: /**
28: * An UiFactory that create a TextBox Ui component.
29: *
30: * @author henrichen
31: *
32: */
33: public class TextBoxFactory extends AbstractUiFactory {
34: public TextBoxFactory(String name) {
35: super (name);
36: }
37:
38: /* (non-Javadoc)
39: * @see org.zkoss.zmobi.UiFactory#create(java.lang.Object, java.lang.String, org.xml.sax.Attributes)
40: */
41: public ZkComponent create(ZkComponent parent, String tag,
42: Attributes attrs, String hostURL, String pathURL) {
43: final String id = attrs.getValue("id"); //id
44: final String title = attrs.getValue("tt"); //title
45: final String constraintsStr = attrs.getValue("cs"); //constraints
46: final String maxSizeStr = attrs.getValue("xs"); //maxSize
47: final int maxSize = Integer.parseInt(maxSizeStr);
48: String text = attrs.getValue("tx"); //text
49: if (text.length() > maxSize)
50: text = text.substring(0, maxSize);
51: final int constraints = Integer.parseInt(constraintsStr);
52:
53: final ZkTextBox tbx = new ZkTextBox(((ZkComponent) parent)
54: .getZkDesktop(), id, title, text, maxSize, constraints);
55: return tbx;
56: }
57:
58: }
|