Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/webobjects/woextensions/WOTableString.java


1   /*
2    * WOTableString.java
3    * © Copyright 2001 Apple Computer, Inc. All rights reserved.
4    * This a modified version.
5    * Original license: http://www.opensource.apple.com/apsl/
6    */
7   
8   package com.webobjects.woextensions;
9   
10  import com.webobjects.appserver.*;
11  import com.webobjects.foundation.*;
12  
13  /*
14   this component exists because browsers are displaying tables in a slightly odd fashion: in a cell that does not contain
15   anything, no borders are drawn which make a page which contains eo with empty properties in a table look odd.
16   this component just puts out an &nbsp when the string is nil
17   */
18  
19  /**
20   * @deprecated
21   * WOTableString is no longer supported
22   */
23  public class WOTableString extends WOComponent {
24      protected Object _value;
25      protected String oldFormatString = null;
26      protected NSTimestampFormatter _cachedTSFormatter = null;
27  
28      public WOTableString(WOContext aContext)  {
29          super(aContext);
30      }
31  
32      public boolean synchronizesVariablesWithBindings() {
33          return false;
34      }
35  
36      public Object value()  {
37          if (_value==null) {
38              _value=valueForBinding("value");
39          }
40          return _value;
41      }
42  
43      public boolean valueIsNonNull()  {
44          Object v=value();
45          return (((v instanceof String) && ((String)v).length()!=0) || (v!=null));
46      }
47  
48      public java.text.Format formatter() {
49          String formatString;
50  
51          if (hasBinding("formatter"))
52              return (java.text.Format)_WOJExtensionsUtil.valueForBindingOrNull("formatter",this);
53          formatString = (String)_WOJExtensionsUtil.valueForBindingOrNull("numberformat",this);
54          
55          if (formatString!=null)
56              return new NSNumberFormatter(formatString);
57          
58          formatString = (String)_WOJExtensionsUtil.valueForBindingOrNull("dateformat",this);
59  
60          if (formatString!=null) {
61              if (!formatString.equals(oldFormatString)) {
62                  oldFormatString = formatString;
63                  _cachedTSFormatter = new NSTimestampFormatter(formatString);
64              }
65              return _cachedTSFormatter;
66          }
67          return null;
68     }
69  
70      protected void _resetInternalCaches() {
71          // ** By setting these to nil, we allow for cycling of the page)
72          _value = null;
73      }
74  
75      public void appendToResponse(WOResponse aResponse, WOContext aContext)  {
76          _resetInternalCaches();
77          super.appendToResponse(aResponse, aContext);
78      }
79  }