Note that there are some explanatory texts on larger screens.

plurals
  1. PODate browsers problem - if manually changed and focus on it - did not save
    text
    copied!<p>I have a problem related to Date type which I'm using in smartgwt.</p> <p>I set up the date to have the possibility to change it manually:</p> <pre><code>setAttribute("useTextField", true); </code></pre> <p>In Firefox and Chrome (and maybe other browsers , except Internet Explorer) if first I'm selecting a date with that pop-up calendar and than change it manually and then let the focus on the date field and going to save the document (actually is a form with multiple fields) the date changed manually it is lost, the date choosed from calendar it is saved. This is not happening in Internet Explorer.</p> <p>In all browsers, if I select from Calendar a date and than change it manually and change the focus from it everythings goes fine - the manually changed date it is saved into db. Need some advices.</p> <p>Thank you a lot.</p> <p><strong>Later edit:</strong></p> <p>I'm using <code>com.smartgwt.client.widgets.form.fields.DateItem widget</code>.</p> <pre><code>DateItem date = new DateItem("A date"); date.setWidth(320); date.setWrapTitle(false); date.setAttribute("useTextField", true); date.setAttribute("inputFormat", "yyyy/MM/dd"); date.setAttribute("displayFormat", "toJapanShortDate"); </code></pre> <p>I'm adding this date on a DynamicForm:</p> <pre><code>DynamicForm form = new DynamicForm(); form.setFields(date); </code></pre> <p>and this form on a VLayout object:</p> <pre><code>VLayout editLayout = new VLayout(30); editLayout.addMember(form); </code></pre> <p>The problem is reproducing in browsers like Firefox &amp; Chrome when:</p> <ol> <li>I'm selecting first the date from calendar - say I'm selecting 2011/02/11</li> <li>I'm changing the day in 2011/02/12 manually - and I'm not changing the focus from this date field</li> <li>I'm pressing the 'Save' button.</li> </ol> <p>After these steps the date is 2011/02/11 and not 2011/02/12 how it should be. In Internet Explorer browser did not happen - the date after the steps above is 2011/02/12!</p> <p><strong>Later edit</strong>:</p> <p>I'm using a <code>DataSource</code> for updating the data.</p> <p>I'm having a <code>UserObject</code> and in the <code>userUpdate</code> method I'm creating this user object first with values from fields (which are on the <code>DynamicForm</code>) - by calling the <code>generateUserObjectFromForm()</code> method</p> <pre><code>UserObject user = generateUserObjectFromForm(); </code></pre> <p>Here, in this method I'm doing something like: <code>user.setAddedDate(date.getValueAsDate())</code>, but here the <code>date.getValueAsDate()</code> value is the one selected from calendar, not the one modified manually.</p> <p>I've tried also with:</p> <pre><code>date.getValue() //Fri Feb 11 00:00:00 GMT+200 2011 date.getValueField() // null date.getValueAsDate() //Fri Feb 11 00:00:00 GMT+200 2011 date.getDisplayField() //null date.getDisplayValue()//l2011/02/11 </code></pre> <p>but none worked properly.</p> <p>I'm using an request object (<code>UserUpdateRequest</code>) for updating the user.</p> <p><code>UserUpdateRequest</code> looks like:</p> <hr> <pre><code>public class UserUpdateRequest implements IsSerializable { UserObject user = null; public UserUpdateRequest () { } public UserUpdateRequest (UserObject user) { this.user = user; } public UserObject getUser () { return user; } } </code></pre> <hr> <pre><code>final UserUpdateRequest request = new UserUpdateRequest(user); </code></pre> <p>and on the RPC user update method I'm sending this <code>UserUpdateRequest</code> request.</p> <p><strong>Later edit (15 february):</strong></p> <p>I've discovered why is happening this issue related to focus, and this is because in the project I'm not using a <code>Button</code> object - and a <code>com.google.gwt.event.dom.client.ClickEvent</code> for it. I'm using a personalized widget:</p> <pre><code>package de.vogella.gwt.helloworld.client; import com.smartgwt.client.widgets.Label; public class buttonLabel extends Label { public buttonLabel (String text, String elementID) { super(); setContents(text); setAutoWidth(); setBaseStyle("wwHoverLabel"); setShowRollOver(true); } } </code></pre> <p>and this use <code>com.smartgwt.client.widgets.events.ClickHandler()</code>.</p> <p>Anyway I do not know how to resolve this ....</p> <p>I've created a small project with this issue where I've put also a <code>Button</code> object (<code>Save1</code>) and also a personalized button <code>buttonLabel</code> (Save2) - both with <code>clickhandlers</code>.</p> <p>Here is the link where you can download sources of this small project I've created: <a href="http://www.fileshare.ro/15452011330.6" rel="nofollow">link</a></p> <p>Case1: say for example we choose date 2011/02/16 and we change manually the date into 2011/02/17 and push the button <code>Save1</code> - everything works fine - the date remains 2011/02/17</p> <p>Case2-a - line <code>Window.alert("2 " + date.getValue());</code> un-commented: say for example we choose date 2011/02/16 and we change manually the date into 2011/02/17 and push the button <code>Save2</code> - in the warning message date value is 2011/02/16 but in the field date remains 2011/02/17</p> <p>Case2-b - line <code>Window.alert("2 " + date.getValue());</code> uncommented: say for example we choose date 2011/02/16 and we change manually the date into 2011/02/17 and push the button <code>Save2</code> - the value from field date is automatically changed to 2011/02/16 </p> <p><strong>Later later edit:</strong></p> <p>Since I can't figure out how to solve my problem I'm thinking for the moment at a temporary solution. So, I have:</p> <pre><code>DateItem date = new DateItem("Adate"); date.setWidth(120); date.setWrapTitle(false); date.setAttribute("useTextField", true); date.setAttribute("inputFormat", "yyyy/MM/dd"); date.setAttribute("displayFormat", "toJapanShortDate"); </code></pre> <p>Because the attribute <code>useTextField</code> is set to <code>true</code> we can see the text entry field. How can I make this text entry field to be un-editable. Actually I want to have only the possibility to choose the date from calendar and not to change it manually. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload