BigDecimalField validation bug - vaadin

BigDecimalField has a nice feature: it allows only digits, "+" and "-" signs, and a decimal separator defined by the current locale ("." or ","). It works fine until someone tries to enter a combination that is not a number or cannot be directly converted to the java BigDecimal type (e.g "123...45.6+++7-89--").
For sach combinations, the validation passes without any warning, and the background business object gets a null value.
Field is in the dialog and every time before opening the dialog there is a call to Binder.readBean() method (in order to set the appropriate data for editing), on "save" button in dialog I call Binder.writeBean(). Problem is that the next time I open the dialog, the problematic BigDecimalField still contains an invalid number entered,
actually Binder.readBean() stops working for that field.
There is a similar bug with IntegerField which I noticed: IntegerField validation bug.
How can I validate BigDecimalField and avoid this bug? How do i get the BigDecimalField to work again and not keep showing invalid data? Is there a elegant way to catch the NumberFormatException that probably occurs somewhere inside the vaadin api, and proces it i.e. warn the user that he has to enter a valid decimal number. Is there a way to do it via Binder?
I am using Vaadin 23.3.0

Checking format error is not yet by default on. You need to enable it by setting enforceFieldValidation=true in feature flags in src/main/resources/vaadin-featureflags.properties file.
com.vaadin.experimental.enforceFieldValidation=true
See more at: https://github.com/vaadin/platform/issues/3066

Related

iOS: Accessibility support for dynamic labels / validation errors?

I want to enable accessibility support in my app where i have In-line validation message (e.g As per below screenshot) when user enters something invalid data. My app doesn't show any error message.
What can be best and intuitive way to inform visual impaired/blind user about wrong data entries. e.g. Username & password mismatch, invalid.
First off, there is no "correct" way to do this. There are just a bunch of ways that work. The "best" way to do this, would be for iOS to have a "required" trait (IMO). But this is not supported, so we have to work with what iOS has given us... hints and labels.
Step 1:
Tell the user what is required. I would do this by adding the information to the hint. I like to add information to the hint that only non-familiar users need. "Power users" of your application will get use to what fields are required (assuming you're going to have return users, some views are just "hit and run" types). But, point being, don't flood users with unnecessary information. Users who visit a particular view frequently will get use to what is required, so keep non-crucial information in the hint. What you want is voiceover to read out the text input fields like this: "Email(accessibilityLabel) text field (the type of object), (pause) This field is required.(hint)" Don't wait until after a failure to provide this information to VoiceOver users. It should just always be set this way. If the type of failure changes, change the hint to adapt to this particular type of failure. If you'd like to keep the hint in sync with the Red highlighted labels, you can consider overriding the functions from the UIAccessibilityProtocol to pull out this information EX:
- (NSString*)accessibilityHint {
return myUILabel.text;
}
This should cause to keep the hint of the object, and the text of your UILabel in sync.
Step 2:
Mark all elements that are not the text input fields, as not accessibility elements. All of the information a user needs about those fields is either stored in the type of the field (a text input field), the label (email/password), or the hint (whether or not it is required). Therefore, we don't want VoiceOver to look at the other elements, because this would be duplicate information.
Step 3:
Use the following line of code:
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, anAccessibilityElement);
In your login action. On a failed login action, you should shift voiceover focus to the element that caused the failure. This informs the user that their action was attempted, and that it failed. It also allows them to easily know which element caused the failure, and that it needs fixed. In the event of multiple failures, make sure you shift focus to the first failure!

Can someone explain Rails behavior for multiple fields with identical names and ids?

I needed to create a input mask for a jQuery datepicker in my Rails app, where the first form field uses m/d/yy format and the datepicker populates a hidden input with the proper database format.
I was using SimpleForm, and so I extended my own input so that the input is preceded by the mask.
I got everything set up and when checking out the browser, it all just worked well before I thought I would be done.
The form ends up with two inputs for the same attribute, each with the same id and name. I never thought this would work. Checking the development log I only see one date getting submitted, the second of the two which is the one that has the proper format for the database.
Is this all okay? Should I take some extra steps even though this appears to work fine, and more importantly, can someone explain what's going on under the hood that results in this behavior?
Thanks!!
Rails uses the Hash params to store fields submitted. When you declare two or more inputs using the same name, it happens the same as if you do something like
h=Hash.new
h[:name]="foo"
h[:name]="bar"
Result is bar because the foo was overwritten. So the "winner" is always the field value which the browser last appended to postdata.
But if I where you, I would not rely on the browser that the second field gets appended at last.

ListGridRecord in smartGWT not displaying items after '<'

I have a ListGrid with ListGridRecords where I am trying to display the straight xml output from a call I'm doing on the backend. Here's an example:
lgr.setAttribute("XML", "<xml><response>Bob</response></xml>");
However, when it goes to display the contents of lgr in the ListGrid, it doesn't display it. (i.e. it is blank). If I make the field editable, I can double click on the cell and it will then display it. Also, if I get rid of the '<' symbols it displays as well. However, that kind of defeats the purpose since I want to display the exact xml used.
Do I need to escape the '<' somehow in the ListGridRecord? What is the best way to do this in GWT?
Ok, just found a thread that seems to solve my problem at least halfway. I would still like to enable the user to copy it without the encoded values, but at least now they can see it. I believe I'll enable some sort of click handler on the fields to to enable the correct copying.
http://www.gwt-ext.com/forum/viewtopic.php?f=7&t=2693

Grails 'scale' dropping decimal digits

Question using Grails 1.3.4 - the 'scale' constraint does not seem to keep my decimals.
I have a field defined as: Float latitude
I have a constraint: latitude(blank: false, range:-360.0f..360.0f, scale:6)
The Oracle 10g field is defined as: NUMBER(10,6)
When I enter a value in Create or Edit, the correct value gets to the database. However, it never displays correctly in Show. If I enter 10.1234567 and update, 10.123457 is in the database but 10.123 displays in Show.
If I Edit, the value shows as 10.123, and if I update without modifying it, 10.123 will be stored in the database, replacing 10.123457 even though I never touched that field.
If I edit the value to 10.456789, but leave another required field blank, the resulting Edit screen with the error message displays the value as 10.457.
Why is Grails continually rounding the value to 3 digits? I tried the field as a Double as well, but same results. I thought maybe it was Oracle, but I tried it with the default dev database, and same result. I thought maybe it was the 'range', but I took that off with the same result.
Hmm - are you sure it's displaying correctly in your database viewer? Also - check your use of tags: See http://www.pubbs.net/200908/grails/38057-grails-user-how-does-rounding-of-decimals-work-in-gsp.html
Wasted too much time trying to figure this out, ended up using the solution suggested by snowmanjack.
The default data binding that occurs with the fieldValue call is truncating it. You can write a new data binder that handles conversion the way you want as described here http://grails.org/doc/latest/guide/single.html#dataBinding
Or you can do the lazy, probably less safe method that I used and access the property directly.
I replaced.
${fieldValue(bean: countryInstance, field: "latitude")}
with
${contryInstance.latitude}

special character coming when i am using & and p

I dont know what exactly i have to type in title for this ,i tried my best
anyway coming to topic
I am making one acc checker for that purpose ,i am sending user and pass from my bsskinedit1 and bsskinedit2
here is my code
s:='http:\\site.com..premlogin='+bsskinedit.text+'&password='+bsskinedit2.text
but it giving some error ,then i used showmessage whats wrong with it then i came with strange result
see below
observer after 4 & and p combining together and appearing as a some new symbol :(
can any one tell me why its coming like this ?
Your code (where you build the URL) is most likely correct (I guess the above has some typos?!), but when you display the URL in a label for instance, the & character is treated as indicator for an accelerator key.
By Windows design, accelerator keys
enable the user to access a menu
command from the keyboard by pressing
Alt along the appropriate letter,
indicated in your code by the
preceding ampersand (&). The character
after the and sign (&) appears
underlined in the menu.
If you want to display the & character itself, you have to set your string variable to &&.
By placing two ampesands together - you state that the character following the first one is not used as the accelerator - rather you actually want to get it (only one) displayed.
Just use your debugger if you want to see the real value that your string variables have, don't output them to a message box or the like... It may have side effects, as you can see.
Regarding the URL you build: I can't possibly know how it has to be correctly, but at least you should use the right slashes!
s := 'http://site.com...'
(All quotes from delphi.about.com)
In addition to what Mef said, you can use OutputDebugString to add your string to the event log in its raw form, so you don't need to modify it before displaying it. Delphi should capture those strings automatically if you're running from the debugger. If you aren't running it from Delphi you can use DebugView instead, which captures the messages from any running applications.

Resources