1. #1
    Ext GWT Premium Member
    Join Date
    Oct 2010
    Location
    Pune, India
    Posts
    25
    Vote Rating
    0
    Av-swdev-4 is on a distinguished road

      0  

    Default How can i resolve Time Field selection problem ?

    How can i resolve Time Field selection problem ?


    Hi All,

    In my application i am using 8 TimeField components in formpanel.


    User can select the value from TimeField component as well as he can Type in to TimeFiled component.
    I am using AM/PM date format in TimeField component.

    Problem is : if user typed value is not available in TimeField store then null will return in binding.

    How to resolve this problem .

    Can you please give me solution other than timeField.setIncrement(1) ?

    because timeField.setIncrement(1) throwing script error in IE8 with Windows ,FF6,FF7.

    Each TimeField contain long list (1440 entries). and total 8 TimeFields having 11520 values.
    This is impact in when formpanel loading in IE8 and FF 6/7 throwing script error.


    If i set timeField.setIncrement(30); (like 10:00 AM 10:30 AM )then this problem will resolve.But another problem is raising.


    If user type valid time like 10:05 AM .this is not available in TimeField store so null will assign in binding.




    Sample code here :

    TimeField timeField = new TimeField();
    timeField.setTriggerAction(TriggerAction.ALL);
    timeField.setForceSelection(false);
    timeField.setTypeAhead(true);
    timeField.setEditable(true);
    timeField.setLazyRender(false);
    timeField.setIncrement(30);
    timeField.setFormat(DateTimeFormat.getFormat("h:mm a"));
    timeField.setFireChangeEventOnSetValue(true);
    timeField.setWidth(90);
    timeField.setMaxHeight(80);
    timeField.setAutoValidate(true);
    timeField.setAllowBlank(false);
    timeField.setValidator(new Validator() {




    @Override
    public String validate(Field<?> field, String value) {
    try {
    if (value != null && !value.isEmpty()) {
    if (value.contains(":")) {
    String time[] = value.split(":");
    if (Integer.parseInt(time[0].toString()) > 12) {
    return LocaleManager.getInstance().getMessage(
    "INVALID_DATE_FORMAT");
    }
    }
    }


    DateTimeFormat dateFormat = DateTimeFormat
    .getFormat("h:mm a");
    Date tempDate = dateFormat.parseStrict(value);
    if ((tempDate.getHours() - 12) > 12
    || tempDate.getMinutes() > 59)
    return LocaleManager.getInstance().getMessage(
    "INVALID_DATE_FORMAT");




    return null;
    } catch (IllegalArgumentException exp) {


    //Window.alert("setTimeFieldProperties Excpetion :"+exp);
    return LocaleManager.getInstance().getMessage(
    "INVALID_DATE_FORMAT");
    }
    }
    });


    TimeFieldBinding startBinding = new TimeFieldBinding(timeField, "startTime") {
    @Override
    protected Object onConvertFieldValue(Object value) {
    if (value == null) {
    return null;
    }
    return ((Time) value).getText();
    }


    @Override
    protected Object onConvertModelValue(Object value) {




    if (value == null) {
    return null;
    }
    DateTimeFormat dateFormat = DateTimeFormat.getFormat("h:mm a");
    Date tempDate = dateFormat.parse(value.toString());
    return timeField.findModel(tempDate);




    }
    };

    i searched so many entries in this forum but not found the proper solution.

    This is pretty urgent.
    Can you please help me out in this issue.
    Thanks

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    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 could change the getValue method of TimeField, that if the value is not in the store automatically creates it and adds it to the store.

  3. #3
    Ext GWT Premium Member
    Join Date
    Oct 2010
    Location
    Pune, India
    Posts
    25
    Vote Rating
    0
    Av-swdev-4 is on a distinguished road

      0  

    Default


    Hi sven,

    Thanks for your response.

    Do you have sample code or example to resolve this problem ?

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    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


    Sorry, I do not have any example code for this.

  5. #5
    Ext GWT Premium Member
    Join Date
    Apr 2011
    Posts
    1
    Vote Rating
    0
    simda15 is on a distinguished road

      0  

    Default Try using timeField.getRawValue()

    Try using timeField.getRawValue()


    Hello,

    I had similar problem and the easiest workaround that I found is to use timeField.getRawValue() method, which really contains what user entered in field, no matter if value is in a model or not. Of course, manual validation and parsing to get Date object is needed if getRawValue() is used.

    I consider this being GXT bug, TimeField.getValue() and getDateValue() should return even dates not contained in the popup menu list if 'forceSelection' property is set to false. What do you think?

    Regards,

    Dafe Simonek

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    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


    I consider this being GXT bug, TimeField.getValue() and getDateValue() should return even dates not contained in the popup menu list if 'forceSelection' property is set to false. What do you think?
    This would be a braking change and cannot be implemented. I would not say it is a bug as it was never intended to work like this. You could easily subclass TimeField to add this feature

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar