01: /* FormateHolder.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Aug 16, 2007 12:43:49 PM 2007, Created by Dennis.Chen
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.jsf.zul.impl;
20:
21: import javax.faces.component.StateHolder;
22: import javax.faces.context.FacesContext;
23:
24: import org.zkoss.lang.Objects;
25:
26: /**
27: * A base class implementation of StateHolder to keep a format.
28: * @author Dennis.Chen
29: *
30: */
31: /*package*/class FormateHolder implements StateHolder {
32:
33: protected String _format;
34:
35: FormateHolder() {
36:
37: }
38:
39: FormateHolder(String format) {
40: _format = format;
41: }
42:
43: protected void formatChanged() {
44:
45: }
46:
47: public void setFormat(String format) {
48:
49: if (Objects.equals(_format, format))
50: return;
51: this ._format = format;
52: formatChanged();
53: }
54:
55: public String getFormat() {
56: return _format;
57: }
58:
59: /* always return false in this method.
60: * @see javax.faces.component.StateHolder#isTransient()
61: */
62: public boolean isTransient() {
63: return false;//always non-transient.
64: }
65:
66: /* (non-Javadoc)
67: * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
68: */
69: public void restoreState(FacesContext context, Object state) {
70: Object values[] = (Object[]) state;
71: setFormat((String) values[0]);
72: }
73:
74: /* (non-Javadoc)
75: * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
76: */
77: public Object saveState(FacesContext context) {
78: Object values[] = new Object[1];
79: values[0] = _format;
80: return values;
81: }
82:
83: /* do nothing in this method.
84: * @see javax.faces.component.StateHolder#setTransient(boolean)
85: */
86: public void setTransient(boolean newTransientValue) {
87: //always non-transient.
88: }
89:
90: }
|