Announcement Announcement Module
Collapse
No announcement yet.
How to format a bound date property ina dialog form? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Ignore me, I looked a bit harder ;-)

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

    Comment


    • #3
      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

      Comment


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

        Just bind it like in the petclinic example for JXdatePciker

        Comment


        • #5
          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.

          Comment


          • #6
            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 :/

            Comment

            Working...
            X