Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    MiniDateRangeItem bug

    Hi all,
    I've a little bug I caanot solve with the MiniDateRangeItem form component.
    In the showcase, it's usage seems very simple, but when I integrate it in my application, I've some problems with it.

    Here is my declaration:
    final MiniDateRangeItem departureDateItem = new MiniDateRangeItem("mdri", "Departure date");
    departureDateItem.setRequired(true);

    By default, the field is disabled (is that normal?). To enable it, I added the following line:
    departureDateItem.setDisabled(false);

    I tough all my problems were fixed, but in facts, not. I can select a date range, but when I modify the value of a combobox manually with a myCombo.setValueMap(..); my MiniDateRangeItem is simply reset!

    And when I submit the form, I get a NullPointerException when smartGWT tries to extract the value in the Item ... Any idea?

    To give you more infos, here is the complete Form declaration:
    Code:
    		final HLayout formLayout = new HLayout(2);
    		final DynamicForm formSearchLoadingUnit = new DynamicForm();
    		formSearchLoadingUnit.setWidth("500px");
    		final TextItem inputLoadingUnit = new TextItem();
    		inputLoadingUnit.setRequired(true);
    		inputLoadingUnit.setTitle("Loading unit");
    		final MiniDateRangeItem departureDateItem = new MiniDateRangeItem("mdri", "Departure date");
    		departureDateItem.setRequired(true);
    		departureDateItem.setDisabled(false);
    		final ComboBoxItem departureTerminalCombo = new ComboBoxItem();  
    		departureTerminalCombo.setTitle("Departure Terminal");  
    		departureTerminalCombo.setType("comboBox");
    		departureTerminalCombo.addKeyUpHandler(new KeyUpHandler() {
    			@Override
    			public void onKeyUp(KeyUpEvent event) {
    				String c = (String) departureTerminalCombo.getValue();
    				departureTerminalCombo.setHint("Please wait...");
    				terminalService.getTerminalsWithCriteria(c, new AsyncCallback<LinkedHashMap<String,String>>() {
    					@Override
    					public void onFailure(Throwable arg0) {
    						departureTerminalCombo.setHint("");
    						SC.warn("Unable to fetch terminals");
    					}
    					@Override
    					public void onSuccess(LinkedHashMap<String, String> valueMap) {
    						departureTerminalCombo.setHint("");
    						departureTerminalCombo.setValueMap(valueMap);
    					}
    				});
    			}
    		});
    		final ComboBoxItem destinationTerminalCombo = new ComboBoxItem();  
    		destinationTerminalCombo.setTitle("Destination Terminal");  
    		destinationTerminalCombo.setType("comboBox");  
    		destinationTerminalCombo.addKeyUpHandler(new KeyUpHandler() {
    			@Override
    			public void onKeyUp(KeyUpEvent event) {
    				String c = (String) destinationTerminalCombo.getValue();
    				destinationTerminalCombo.setHint("Please wait...");
    				terminalService.getTerminalsWithCriteria(c, new AsyncCallback<LinkedHashMap<String,String>>() {
    					@Override
    					public void onFailure(Throwable arg0) {
    						destinationTerminalCombo.setHint("");
    						SC.warn("Unable to fetch terminals");
    					}
    					@Override
    					public void onSuccess(LinkedHashMap<String, String> valueMap) {
    						destinationTerminalCombo.setHint("");
    						destinationTerminalCombo.setValueMap(valueMap);
    					}
    				});
    			}
    		});
    		final RadioGroupItem showActive = new RadioGroupItem();
    		showActive.setVertical(false);
    		showActive.setTitle("Show active transports only");
    		LinkedHashMap<String, String> yesNo = new LinkedHashMap<String, String>();
    		yesNo.put("1", "Yes");  
    		yesNo.put("0", "No");
    		showActive.setValueMap(yesNo);
    		showActive.setDefaultValue("0");
    		formSearchLoadingUnit.setFields(inputLoadingUnit,departureDateItem,departureTerminalCombo,destinationTerminalCombo,showActive);
    		formSearchLoadingUnit.setTitleWidth(175);
    		
    		final Button searchItu = new Button("Search");
    		searchItu.setStyleName("searchButton");
    		
    		formLayout.addMember(formSearchLoadingUnit);
    		formLayout.addMember(searchItu);
    Thanks for your help because this is really blocking me ...

    #2
    Not really following the description here - are you saying that calling setValueMap() is causing a completely unrelated component to be reset?

    You've also posted another completely mysterious result where you claim date formatting doesn't work - have you loaded third party JavaScript libraries into the page?

    About the NullPointerException, for help with that, post it (always do this).

    Comment


      #3
      are you saying that calling setValueMap() is causing a completely unrelated component to be reset?
      Yes, that's it. But I dont't think it's the setValueMap() function in particular as when the RPC call is made (see code above), the reset is made approximatively at the same time as the "Please wait" label is set and removed (that happen too quickly to see when exactly).


      have you loaded third party JavaScript libraries into the page?
      Yes, I've loaded the JQuery framework as I need it somewhere else on the page. I think there is no relation with the bug because when I remove all Jquery custom code and framework, the reset bug is still there.

      For the stacktrace, as ther is a limitation in the file size, I will upload the files in the following posts, explaining what I upload

      Comment


        #4
        1. This is the GWT Development stacktrace when I modify the date
        Attached Files

        Comment


          #5
          End of the GWT logs when selecting a date.
          When set to WARN the Smartgwt console shows this:

          10:51:33.638:WARN:DynamicForm:isc_RelativeDateItem_0_editor:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_0 name:iconPlaceholder]
          10:51:33.647:WARN:DynamicForm:isc_RelativeDateItem_0_editor:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_0 name:iconPlaceholder]
          10:51:35.797:WARN:DynamicForm:isc_RelativeDateItem_1_editor:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_1 name:iconPlaceholder]
          10:51:35.803:WARN:DynamicForm:isc_RelativeDateItem_1_editor:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_1 name:iconPlaceholder]
          Attached Files

          Comment


            #6
            2. Modifying the combobox value : no error is raised in WARN. I attached the smartgwt console output to this post.
            Attached Files

            Comment


              #7
              3. Submitting the form with the date range set
              Attached Files

              Comment


                #8
                Those aren't stack traces. For what a stack trace is and how to capture it, please see the FAQ.

                Probably the best thing to do is create a standalone test case that reproduces the problem *without JQuery*, if you succeed, we can then run it to see the problem.

                Comment


                  #9
                  Here is a very little test case I wrote quickly and shows my problem. I don't put the whole project as it's a trivial one, I just put you

                  - The java entry point file :
                  Code:
                  package be.uniway.rvk.test.daterange.client;
                  
                  import com.google.gwt.core.client.EntryPoint;
                  import com.google.gwt.core.client.GWT;
                  import com.google.gwt.user.client.ui.RootPanel;
                  import com.smartgwt.client.widgets.form.DynamicForm;
                  import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
                  import com.smartgwt.client.widgets.form.fields.MiniDateRangeItem;
                  import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
                  import com.smartgwt.client.widgets.form.fields.events.KeyUpHandler;
                  import com.smartgwt.client.widgets.layout.HLayout;
                  
                  public class SmartGwtDateRangeTest implements EntryPoint {
                  
                  	private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
                  
                  	public void onModuleLoad() {
                  		final HLayout formLayout = new HLayout(2);
                  		final DynamicForm formSearchLoadingUnit = new DynamicForm();
                  		final MiniDateRangeItem departureDateItem = new MiniDateRangeItem("mdri", "Departure date");
                  		departureDateItem.setRequired(true);
                  		final ComboBoxItem departureTerminalCombo = new ComboBoxItem();  
                  		departureTerminalCombo.setTitle("Departure Terminal");  
                  		departureTerminalCombo.setType("comboBox");
                  		departureTerminalCombo.addKeyUpHandler(new KeyUpHandler() {
                  			@Override
                  			public void onKeyUp(KeyUpEvent event) {
                  				String c = (String) departureTerminalCombo.getValue();
                  				departureTerminalCombo.setHint("Please wait...");
                  			}
                  		});
                  		formSearchLoadingUnit.setFields(departureDateItem,departureTerminalCombo);
                  		formLayout.addMember(formSearchLoadingUnit);
                  		RootPanel.get("formcontainer").add(formLayout);
                  	}
                  }
                  and the HTML used with it:
                  Code:
                  <!doctype html>
                  
                  <html>
                    <head>
                      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
                      <link type="text/css" rel="stylesheet" href="SmartGwtDateRangeTest.css">
                      <title>Web Application Starter Project</title>
                    </head>
                  
                    <body>
                  	<script>
                  		var isomorphicDir = "smartgwtdaterangetest/sc/";
                  	</script>
                  	<script type="text/javascript" language="javascript" src="smartgwtdaterangetest/smartgwtdaterangetest.nocache.js"></script>
                      <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
                      
                      <h1>Web Application Starter Project</h1>
                  
                      <div id="formcontainer"></div>
                      <div id="buttoncontainer"></div>
                      
                      
                    </body>
                  </html>
                  As I said, I've created that from the default GWT project, so the only thing I changed to make it work is the reference to SmartGwtPro in the .gwt.xml file, and the same bug occurs : by default, my MiniDateRange is disabled, and when I select a date and the combo's onKeyUp method is called, the MiniDateRange is reset ...
                  Last edited by romain.vdk; 23 Aug 2010, 23:34.

                  Comment


                    #10
                    This issue should now be resolved - please try the latest nightly build and let us know if you still see it

                    Comment


                      #11
                      Hi,
                      sorry for the delay, I was on holliday.
                      I downloaded the latest build, n°1407 but the same bug remains with the test case provided here and my bigger project ...

                      Comment


                        #12
                        Can you try the latest build from here?

                        Comment


                          #13
                          It doesn't work either.
                          To make sure it is not a cache problem, I tested it with Chrome and Firefox with CTRL+F5 and clear cache but no change ...

                          Comment


                            #14
                            Unable to reproduce the issue. See this capture.

                            I tried it in Firefox and Safari. As you can see, the MiniDataRangeItem is not disabled and the value is not reset when the ComboBox's keyUp method is called.

                            Sanjiv

                            Comment


                              #15
                              I don't understand ... If it's working for you and not for me, it must be something different. I've downloaded the new versions of smartgwt and smartgwt-skins. Is there also a different version of smart GWT pro ?
                              Do you use custome parameters in the .gwt.xml file ?
                              I try to understand what different things I have that make the date item not work here ...

                              Comment

                              Working...
                              X