I have a problem related to the Date type that I use in smartgwt.
I set the date to be able to change it manually:
setAttribute("useTextField", true);
In Firefox and Chrome (and possibly other browsers other than Internet Explorer), if I first select a date with this pop-up calendar, then change it manually, and then let me focus on the date field and am going to save the document (this is actually a form with several fields), the date changed manually, it is lost, the date selected from the calendar is saved. This does not happen in Internet Explorer.
In all browsers, if I select a date from the Calendar and then change it manually and change the focus to it, everything will be fine - the date of the manual change will be saved in db. Need some advice.
Thank you very much.
Edit later:
I use com.smartgwt.client.widgets.form.fields.DateItem widget.
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");
I am adding this date to DynamicForm:
DynamicForm form = new DynamicForm();
form.setFields(date);
and this form on the VLayout object:
VLayout editLayout = new VLayout(30);
editLayout.addMember(form);
The problem is reproduced in browsers such as Firefox and Chrome when:
- I choose the first date from the calendar - I will say that I choose 2011/02/11
- I manually change the day in 2011/02/12 - and I do not change the focus from this date field.
- I click the "Save" button.
After these steps, the date is 2011/02/11, not 2011/02/12, as it should be. Internet Explorer did not happen - the date after the above steps is 2011/02/12!
Edit later :
I use DataSourceto update data.
I have UserObjectand in the method userUpdateI create this user object first with the values from the fields (which are on DynamicForm) - by calling the methodgenerateUserObjectFromForm()
UserObject user = generateUserObjectFromForm();
, , - :
user.setAddedDate(date.getValueAsDate()),
date.getValueAsDate() - , , , .
:
date.getValue()
date.getValueField()
date.getValueAsDate()
date.getDisplayField()
date.getDisplayValue()
.
(UserUpdateRequest) .
UserUpdateRequest :
public class UserUpdateRequest implements IsSerializable
{
UserObject user = null;
public UserUpdateRequest ()
{
}
public UserUpdateRequest (UserObject user)
{
this.user = user;
}
public UserObject getUser ()
{
return user;
}
}
final UserUpdateRequest request = new UserUpdateRequest(user);
RPC UserUpdateRequest.
(15 ):
, , , Button - com.google.gwt.event.dom.client.ClickEvent . :
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);
}
}
com.smartgwt.client.widgets.events.ClickHandler().
, ....
, Button (Save1), buttonLabel (Save2) - clickhandlers.
, , :
1:
, 2011/02/16, 2011/02/17 Save1 - - 2011/02/17
Case2-a-line
Window.alert("2 " + date.getValue()); :
, 2011/02/16, 2011/02/17 Save2 - 2011/02/16, 2011/02/17
Case2-b -
Window.alert("2 " + date.getValue()); :
, 2011/02/16, 2011/02/17 Save2 - 2011/02/16
:
, , .
, :
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");
useTextField true, . . .