Results 1 to 6 of 6

Thread: How to format a bound date property ina dialog form?

  1. #1

    Default How to format a bound date property ina dialog form?

    Hi folks, I have a display only field in a form that id like to be able to associate some formatting with, along the lines of SimpleDate format.

    Im sure theres an accepted way of doing this that Imm not getting just yet!

    So, in the code beneath, Id like the displayed string associated with the "timestamp" property to be formattable.

    Any hints?

    Thanks

    Alan

    Code:
    protected JComponent createFormControl() {
            
            TableFormBuilder formBuilder = new TableFormBuilder(getFormModel());                       
            formBuilder.add("tagId")[1].setEnabled(false);
            formBuilder.add("timestamp")[1].setEnabled(false);
            formBuilder.row();
            formBuilder.addTextArea("tagEvent.description");
            
            return formBuilder.getForm();        
        }

  2. #2

    Default

    Ignore me, I looked a bit harder ;-)

    Code:
    getFormModel().registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"), false));

  3. #3
    Join Date
    May 2005
    Location
    Finland
    Posts
    10

    Default

    Quote Originally Posted by amcauley

    Code:
    getFormModel().registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"), false));
    Could someone give an example how to do this kind of simple date formatting with 'RCP-0.1', please? I can't figure it out...

    Regards,
    Antti

  4. #4
    Join Date
    May 2005
    Posts
    394

    Default

    Take a look at
    http://opensource2.atlassian.com/pro...browse/RCP-204

    Just bind it like in the petclinic example for JXdatePciker

  5. #5
    Join Date
    Aug 2006
    Posts
    1

    Question Still the date

    Hey guys,

    I have a problem with the java.util.Date datatype binding, too. I have read the ...RCP-204 already. Unfortunately it didn't bring me very far.

    The problem I am stuck with is, that I would like to set another date format than the one that is used by default. I don't need any other editor. A simple jTextfield is working fine for me.

    I guess there is somewhing working in the background already, since I get a "dateformat not valid" when I type into the fields I bound to some java.util.Date fields (e.g. by formBuilder.add("birthdate"); ).

    So, naive as I am, I hoped I could do something like this:

    <bean id="simpleDateFormat"
    class="java.text.SimpleDateFormat">
    <constructor-arg>
    <value type="java.lang.String">dd.MM.yyyy</value>
    </constructor-arg>
    </bean>

    <bean id="customDateEditor"
    class="org.springframework.beans.propertyeditors.C ustomDateEditor">
    <constructor-arg ref="simpleDateFormat" />
    <constructor-arg>
    <value type="boolean">false</value>
    </constructor-arg>
    </bean>

    And then hand over the SimpleDateFormatter to a Registry or do the Binding in a different but similar way. However, I could not figure out how to do it.

    I searched the web, this forum, tried a lot but didn't find any answers.
    I desperately need some advice.

    So if you have any idea, PLEASE redeem me!
    - Thanks in advance.

  6. #6
    Join Date
    May 2005
    Posts
    394

    Default

    The NachoCalendar binding supports a simpleDateFormat, thanks to Benoit and it's in SVN in the tiger module with javadocs on how to use it.

    I don't know how to do it for the SimpleDateFormatter though :/

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Replies: 2
    Last Post: May 13th, 2005, 05:42 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
  •