1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default Answered: Wrong display DateField

    Answered: Wrong display DateField


    Hi guys, I try to display some Fields<> into an LayoutContainer() with FormLayout() like here:

    Code:
            formData = new FormData("90%");
            right = new LayoutContainer();
            right.setStyleAttribute("paddingLeft", "10px");
            layout = new FormLayout();
            layout.setLabelAlign(LabelAlign.LEFT);
            right.setLayout(layout);
    Code:
                                  if ("DATA".equals(type)) {
                                        DateField _date = new DateField();
                                        _date.setId("data");
                                        _date.setItemId("customField" + i);
                                        DateTimePropertyEditor dateFormat = new DateTimePropertyEditor(
                                                "MM-dd-yyyy");
                                        _date.setPropertyEditor(dateFormat);
                                        if ("true".equals(req)) {
                                            _date.setAllowBlank(false);
                                        }
                                        if (value != null && !("".equals(value))) {
                                            _date.setValue(dateFormat
                                                    .convertStringValue(value));
                                        }
                                        _date.setFieldLabel(st);
                                        right.add(_date, formData);
                                    }
    Is there any known bug concerning this ? Has anyone experienced this problem before ?

  2. IDs have to be unique. In Your code i never see you increasing "i"

  3. #2
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default


    here are the screenshots (sory for 2xPosting)
    1.
    Data1.jpg
    2.

    Data2.jpg
    3.
    Data3.jpg
    4.
    Data4.jpg

  4. #3
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Answers
    60
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You should add some description on what youre screenshots are actually showing. You should also try to reproduce this in a small, standalone testcase implementing EntyrPoint.

  5. #4
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default


    Code:
    public class SomeClass implements EntryPoint {
    
        public static Button submit;
        public static Button anulla;
        public static FormPanel panel;
        private static LayoutContainer right;
        private static FormData formData;
    
        public void addForm(ContentPanel cp) {
            cp.setHeaderVisible(false);
            formData = new FormData("90%");
            FormPanel panel = new FormPanel();
            panel.setFrame(true);
            panel.setHeaderVisible(false);
            panel.setLabelAlign(LabelAlign.LEFT);
            panel.setButtonAlign(HorizontalAlignment.CENTER);
    
            LayoutContainer main = new LayoutContainer();
            main.setLayout(new ColumnLayout());
    
            LayoutContainer left = new LayoutContainer();
            left.setStyleAttribute("paddingRight", "10px");
            FormLayout layout = new FormLayout();
            layout.setLabelAlign(LabelAlign.LEFT);
            left.setLayout(layout);
    
            TextField<String> nome = new TextField<String>();
            nome.setFieldLabel("Nome");
            nome.setAllowBlank(false);
            left.add(nome, formData);
    
            TextField<String> note = new TextField<String>();
            note.setFieldLabel("Note");
            left.add(note, formData);
    
            TextField<String> oggetto = new TextField<String>();
            oggetto.setFieldLabel("Oggetto");
            left.add(oggetto, formData);
    
            TextField<String> ricerca1 = new TextField<String>();
            ricerca1.setFieldLabel("Ricerca1");
            left.add(ricerca1, formData);
    
            TextField<String> ricerca2 = new TextField<String>();
            ricerca2.setFieldLabel("Ricerca2");
            left.add(ricerca2, formData);
    
            right = new LayoutContainer();
            right.setStyleAttribute("paddingLeft", "10px");
            layout = new FormLayout();
            layout.setLabelAlign(LabelAlign.LEFT);
            right.setLayout(layout);
    
            DateTimePropertyEditor dateFormat = new DateTimePropertyEditor(
                    "MM-dd-yyyy");
            List<Field> list = new ArrayList<Field>();
            DateField data1 = new DateField();
            data1.setFieldLabel("data1");
            data1.setPropertyEditor(dateFormat);
            list.add(data1);
            DateField data2 = new DateField();
            data2.setFieldLabel("data2");
            data2.setPropertyEditor(dateFormat);
            list.add(data2);
            DateField data3 = new DateField();
            data3.setFieldLabel("data3");
            data3.setPropertyEditor(dateFormat);
            list.add(data3);
            DateField data4 = new DateField();
            data4.setFieldLabel("data4");
            data4.setPropertyEditor(dateFormat);
            list.add(data4);
            DateField data5 = new DateField();
            data5.setFieldLabel("data5");
            data5.setPropertyEditor(dateFormat);
            list.add(data5);
            int i = 0;
            for (Field f : list) {
                f.setId("custom" + i); //if I remove this it works WHY?
                f.setItemId("data");
                ((DateField) f).setAllowBlank(false);
                right.add(f, formData);
            }
            main.add(left, new ColumnData(.5));
            main.add(right, new ColumnData(.5));
            panel.add(main, new FormData("90%"));
            submit = new Button("Modifica");
            // submit.addSelectionListener(MyButtons.documentHandler.editDocument());
            anulla = new Button("Anulla");
            // anulla.addSelectionListener(MyButtons.documentHandler.editDocument());
    
            panel.addButton(submit);
            panel.addButton(anulla);
            panel.setButtonAlign(HorizontalAlignment.CENTER);
            FormButtonBinding binding = new FormButtonBinding(panel);
            binding.addButton(submit);
            cp.add(panel);
        }
        @Override
        public void onModuleLoad() {
            ContentPanel cp = new ContentPanel();
            cp.setWidth(600);
            cp.setHeaderVisible(false);
            addForm(cp);
            RootPanel.get().add(cp);
        }
    }

  6. #5
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Answers
    60
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    IDs have to be unique. In Your code i never see you increasing "i"

  7. #6
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default


    Yeah I forgot about unique id's and I kind of relied on id when identifying the field for later usage. It's clear now where I was wrong, Thanks sven.

Thread Participants: 1