Date browsers problem - if manually changed and focus on it - did not save -
i have problem related date type i'm using in smartgwt.
i set date have possibility change manually:
setattribute("usetextfield", true);
in firefox , chrome (and maybe other browsers , except internet explorer) if first i'm selecting date pop-up calendar , change manually , let focus on date field , going save document (actually form multiple fields) date changed manually lost, date choosed calendar saved. not happening in internet explorer.
in browsers, if select calendar date , change manually , change focus everythings goes fine - manually changed date saved db. need advices.
thank lot.
later edit:
i'm using 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'm adding date on dynamicform:
dynamicform form = new dynamicform(); form.setfields(date);
and form on vlayout object:
vlayout editlayout = new vlayout(30); editlayout.addmember(form);
the problem reproducing in browsers firefox & chrome when:
- i'm selecting first date calendar - i'm selecting 2011/02/11
- i'm changing day in 2011/02/12 manually - , i'm not changing focus date field
- i'm pressing 'save' button.
after these steps date 2011/02/11 , not 2011/02/12 how should be. in internet explorer browser did not happen - date after steps above 2011/02/12!
later edit:
i'm using datasource
updating data.
i'm having userobject
, in userupdate
method i'm creating user object first values fields (which on dynamicform
) - calling generateuserobjectfromform()
method
userobject user = generateuserobjectfromform();
here, in method i'm doing like: user.setaddeddate(date.getvalueasdate())
, here date.getvalueasdate()
value 1 selected calendar, not 1 modified manually.
i've tried with:
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
but none worked properly.
i'm using request object (userupdaterequest
) updating user.
userupdaterequest
looks like:
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);
and on rpc user update method i'm sending userupdaterequest
request.
later edit (15 february):
i've discovered why happening issue related focus, , because in project i'm not using button
object - , com.google.gwt.event.dom.client.clickevent
it. i'm using personalized widget:
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); } }
and use com.smartgwt.client.widgets.events.clickhandler()
.
anyway not know how resolve ....
i've created small project issue i've put button
object (save1
) , personalized button buttonlabel
(save2) - both clickhandlers
.
here link can download sources of small project i've created: link
case1: example choose date 2011/02/16 , change manually date 2011/02/17 , push button save1
- works fine - date remains 2011/02/17
case2-a - line window.alert("2 " + date.getvalue());
un-commented: example choose date 2011/02/16 , change manually date 2011/02/17 , push button save2
- in warning message date value 2011/02/16 in field date remains 2011/02/17
case2-b - line window.alert("2 " + date.getvalue());
uncommented: example choose date 2011/02/16 , change manually date 2011/02/17 , push button save2
- value field date automatically changed 2011/02/16
later later edit:
since can't figure out how solve problem i'm thinking moment @ temporary solution. so, have:
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");
because attribute usetextfield
set true
can see text entry field. how can make text entry field un-editable. want have possibility choose date calendar , not change manually.
the following code should work.
dateitem date = new dateitem("adate"); date.setattribute("usetextfield", true); date.setattribute("inputformat", "yyyy/mm/dd"); date.setattribute("displayformat", "tojapanshortdate"); textitem textitem = new textitem(); textitem.setattribute("readonly", "true"); date.settextfieldproperties(textitem);
Comments
Post a Comment