Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Limiting input in FormFields(Using the Format and ValueFormat properties)
Limiting input in FormFields [message #1003550] Mon, 21 January 2013 13:56 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 346
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I have FormFields of various types (AbstractLongField, AbstractIntegerField, AbstractDoubleField, AbstractStringField) for which I want to limit the input. Some of the constraints I would like to enforce as the user types (and not only when he leaves the field and it is validated) are:

  • suppression of non-numeric input in number fields
  • suppression of digits in string fields
  • limiting the number of characters that can be entered in a field


I've tried out some things, but can still not do all of the above:

  • I can limit the number of characters accepted in a StringField by using getConfiguredMaxLength()
  • I can validate any input after the field loses focus, I can return "sanitised" data after validation of throw an exception to indicate faulty input
  • using the ValidateOnAnyKey property on StringFields I manage to trigger execValidateValue on each keypress, but I did not manage to write back a "sanitised" version of the rawValue (i.e. removing digits as they are typed) -> how do I do that?
  • I have not found a way to limit the input length on numbers or to validate numbers as the user types (there is no ValidateOnAnyKey property on any of the number fields)
  • I have managed to use the "Format" property on DateFields to define how I want dates to be formatted, but I have not found out how to use the "Format" property on any other field nor what the ValueFormat property of StringFields is used for


Is there any documentation on how to do what I want?
Re: Limiting input in FormFields [message #1003858 is a reply to message #1003550] Tue, 22 January 2013 06:21 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 818
Registered: October 2011
Senior Member
Are you using Swing UI or SWT UI ?

have you see differences between both UI ?
=> If yes, one UI is probably not completely implemented and we need to fix it.


I am afraid that the kind of control you want to achieve requires
- Custom Fields and custom UI Renderer
- Modification of Scout

I think that you can do suggestions.

Re: Limiting input in FormFields [message #1003954 is a reply to message #1003858] Tue, 22 January 2013 10:16 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 346
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Jeremie Bresson wrote on Tue, 22 January 2013 07:21
Are you using Swing UI or SWT UI ?

My "Playground application" I use to learn all I can about Scout is using both Swing and SWT. Our "real" application will use SWT only.

Jeremie Bresson wrote on Tue, 22 January 2013 07:21
have you see differences between both UI ?
=> If yes, one UI is probably not completely implemented and we need to fix it.

I've seen some differences between Swing and UI with regard to validation:

  • StringField.execValidateValue without ValidateOnAnyKey (filtering out all input except for [A-Za-z]) works for both UIs when leaving the field
  • StringField.execValidateValue with ValidateOnAnyKey (filtering out all input except for [A-Za-z]) is called after each keypress for both UIs, however the modified return value is not written back to the input field with either of them. When leaving the field, in SWT the value is then replaced, in Swing it isn't (but should be, I think)
  • other than that, the two implementations seem to behave the same as far as I can tell


Jeremie Bresson wrote on Tue, 22 January 2013 07:21
I am afraid that the kind of control you want to achieve requires
- Custom Fields and custom UI Renderer
- Modification of Scout


I think that you can do suggestions.[/quote]
Do you want me to make them here? Or should I open a bug report? (One of my colleagues has already opened a ticket for supporting ValidateOnAnyKey on Fields other than StringField (https://bugs.eclipse.org/bugs/show_bug.cgi?id=398283)).

The remaining suggestion would be that the mechanism of replacing the field contents with the return value of execValidateValue also function for ValidateOnAnyKey=true.
Re: Limiting input in FormFields [message #1005233 is a reply to message #1003954] Thu, 24 January 2013 17:26 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 118
Registered: November 2010
Senior Member
I appreciate the time you have taken to make a deep test of scout. Sharing on the forum let us know you, your concerns, your vision from Eclipse Scout. It is very challenging.

I have given my opinion on bug 398283.

Urs Beeli wrote on Tue, 22 January 2013 11:16

Do you want me to make them here? Or should I open a bug report?


If you want to discuss something, or if you look for answers. The forum is the right place.

If you consider that something needs to be changed in the code (because it is a bug, or an enhancement request) a bug in bugzilla is necessary. Please add as much information as possible the bug (if necessary: minimal example, step to reproduce, platform...). This helps a lot to understand the request correctly.

You can also combine both approaches (if you link the bug and the forum post in both directions, there is no problem at all).

I can not assure you that every opened bug will be solved immediately, because there is a lot to do. But it is the only way to improve eclipse scout on the long term.

Re: Limiting input in FormFields [message #1006371 is a reply to message #1005233] Thu, 31 January 2013 07:06 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 346
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I opened Bug 399583 for misbehaviour of execValidatValue when ValidateOnAnyKey is set
Re: Limiting input in FormFields [message #1006378 is a reply to message #1006371] Thu, 31 January 2013 07:39 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 346
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I just realised that most of this thread so far discussed what I can and cannot do using the execValidateValue method.

Another part of my intial question was how to use the following two properties:

  • Format
  • ValueFormat


Is there any documentation on these? Or can anyone here give me a rough overview on how to use these on StringFields, NumberFields, (SmartFields too?). I've found out how to use Format for a DateField.
Re: Limiting input in FormFields [message #1006386 is a reply to message #1006378] Thu, 31 January 2013 08:31 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 818
Registered: October 2011
Senior Member
Thanks for your Bug 399583, I will try look into it.

---
About Format and ValueFormat on SmartField:

I like to make a similar answer I did on Bug 398283#3.

On a SmartField, the user input (Text, row selection in the proposal list...) is sent to the LookupCall. The Text of the chosen LookupRow defines what will be displayed as text value on the UI.

That is why you do not have any Format or ValueFormat property on a SmartField.

---
About Format and ValueFormat on other fields:

I think that it influences the default behavior of execFormatValue() (see the "input validation" flow diagram)

You are right, we need to define more clearly the different possible combinations (for the different type of value fields).
Re: Limiting input in FormFields [message #1008376 is a reply to message #1006386] Tue, 12 February 2013 08:35 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 346
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks for your update.
Previous Topic:child page do not decorate untll it's been clicked in an outline based application
Next Topic:ListBox
Goto Forum:
  


Current Time: Sun Dec 21 05:36:09 GMT 2014

Powered by FUDForum. Page generated in 0.12206 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software