Announcement Announcement Module
Collapse
No announcement yet.
datechooser component - first try Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • datechooser component - first try

    Hello,

    This is date calendar component for RCP application.
    Classes :

    http://www.snpe.co.yu/JCalendarExt.java

    JCalendarExt is JCalendar with 2 added buttons : today and clear

    http://www.snpe.co.yu/JTextFieldDateChooser.java

    It is like TextFieldDateChooser from toedter's general forum (thread 'null date')

    You have to add toedter's jcalendar libary

    Using :

    standard property editor like :

    http://www.snpe.co.yu/DefaultDateEditor.java

    you have to add registry for editor in spring's xml

    when you bind component to JTextField you create datechooser with:

    JtextFieldDateChooser datechooser = new JTextFieldDateChooser(components[1])

    and add datechooser in form except JTextField component

    RCP binding and validation work with JTextField components and we have :

    null value
    invalid value (I need this for search; for example, If i have date format
    dd.MM.yyyy and value __.03.____ in text components system search for all
    dates in Mart)

    screenshoots : http://www.snpe.co.yu/datechooser_search.png (no validation in search mode)
    http://www.snpe.co.yu/datechooser_insert.png (invalid value)

    regards

  • #2
    Hi snpe,

    I'm trying to follow your example but am having a little problem. You metion several classes, DefaultDateEditor, JCalendarExt, and JTextFieldDateChooser. Which one gets registered as the Property Editor? Right now I have DefaultDateEditor. Second, Binding... my code looks like this:

    Code:
    private JTextFieldDateChooser istatusDate;
    
    istatusDate = new JTextFieldDateChooser();
    
    getFormModel().bind(istatusDate, "istatusDate");
    but the last line draws a syntax erros because the bind method(s) don't understand the type JTextFieldDateChooser. How do I cast that to a JTextField?

    TIA

    Comment


    • #3
      Scott,
      You have to do next :

      a) define property editor for date field in spring xml file , for example

      Code:
      <bean id="propertyEditorRegistry"
      		class="org.springframework.richclient.application.support.DefaultPropertyEditorRegistry">
      		<property name="propertyEditors">
      			<list>
      				<props>
      					<prop key="objectClass">java.lang.Long</prop>
      					<prop key="propertyEditorClass">yu.co.snpe.dbtable.propertyeditor.DefaultLongEditor</prop>
      				</props>
      				<props>
      					<prop key="objectClass">java.lang.Integer</prop>
      					<prop key="propertyEditorClass">yu.co.snpe.dbtable.propertyeditor.DefaultIntegerEditor</prop>
      				</props>
      				<props>
      					<prop key="objectClass">java.util.Date</prop>
      					<prop key="propertyEditorClass">yu.co.snpe.dbtable.propertyeditor.DefaultDateEditor</prop>
      				</props>		
      				<props>
      					<prop key="objectClass">java.math.BigDecimal</prop>
      					<prop key="propertyEditorClass">yu.co.snpe.dbtable.propertyeditor.DefaultBigDecimalEditor</prop>
      				</props>
      			</list>
      		</property>
      	</bean>
      DefaultDateEditor is like this :
      Code:
       * Copyright 2002-2004 the original author or authors.
       * 
       * Licensed under the Apache License, Version 2.0 &#40;the "License"&#41;; you may not
       * use this file except in compliance with the License. You may obtain a copy of
       * the License at
       * 
       * http&#58;//www.apache.org/licenses/LICENSE-2.0
       * 
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
       * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
       * License for the specific language governing permissions and limitations under
       * the License.
       */
      package yu.co.snpe.dbtable.propertyeditor;
      
      import java.text.SimpleDateFormat;
      
      import org.springframework.beans.propertyeditors.CustomDateEditor;
      
      /**
       * @author snpe
       *
       */
      public class DefaultDateEditor extends CustomDateEditor &#123;
      
          public DefaultDateEditor&#40;String dateFormat&#41; &#123;
              super&#40;new SimpleDateFormat&#40;dateFormat&#41;, true&#41;;
          &#125;
      
          public DefaultDateEditor&#40;&#41; &#123;
              super&#40;new SimpleDateFormat&#40;"dd.MM.yyyy"&#41;, true&#41;;
          &#125;
      
      &#125;
      Now bind date property form bean to simple JTextField :

      Code:
      JTExtField textField = new JTextField&#40;&#41;;
      swingModel.bind&#40;textField,"dat"&#41;;
      spring rcp do standard property editor validation for date - I can set null and invalid value
      I need invalid value in field, because I have search/filter with sql expression, for example
      __-MAR-200_ for search mont Mart in year 2000-2009
      I create calendar compnent now with :
      Code:
      JTextFieldDateChooser datComp = new JTextFieldDateChooser&#40;textField&#41;;
      I add only datComp to GUI, not textField (textField is part of datComp)

      You have to disable button in datComp when disable textField, too

      regards

      Comment


      • #4
        Originally posted by snpe
        I create calendar compnent now with :
        Code:
        JTextFieldDateChooser datComp = new JTextFieldDateChooser&#40;textField&#41;;
        I add only datComp to GUI, not textField (textField is part of datComp)
        This is the part I did not have. Thanks, this worked!!!

        Comment

        Working...
        X