Results 1 to 4 of 4

Thread: datechooser component - first try

  1. #1
    Join Date
    Aug 2004
    Posts
    203

    Default 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. #2

    Default

    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
    -ScottTavares-

  3. #3
    Join Date
    Aug 2004
    Posts
    203

    Default

    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

  4. #4

    Default

    Quote 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!!!
    -ScottTavares-

Similar Threads

  1. ShuttleList component and bindings
    By lstreepy in forum Swing
    Replies: 15
    Last Post: Dec 13th, 2005, 11:06 AM
  2. Reusable component architecture best practices?
    By rebornspirit in forum Architecture
    Replies: 3
    Last Post: Oct 18th, 2005, 07:57 AM
  3. Notification component in a clustered environment
    By spring04 in forum Architecture
    Replies: 5
    Last Post: Oct 13th, 2005, 02:51 AM
  4. Replies: 3
    Last Post: Dec 14th, 2004, 07:04 AM
  5. shared buisness component.
    By djeang in forum Architecture
    Replies: 1
    Last Post: Oct 25th, 2004, 03:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •