Does a number or currency text field exist

So I want to display an input field to the user only depending on the type that I want I only want them able to enter the data type I want. I have a few cases that I’m hoping to get the input formatted for

1)currency
2) int’s
3)doubles or floats, some number with a decimal point

Not sure if there already exists things that can do this or not thought I’d ask the forum. If not are there any addons I might be able to leverage to get this functionality?

Thanks

You can use a PropertyFormatter to format and parse field values in a Form.

See for example:

[list]

[]

DoubleDecimalFormatter.java

[
]

FillEditor.java
- how it’s used
[*]

run the app
(user/pw: demo/demo)

[/list]The DecimalFormat used in the example is rather picky about the input format, it easily fails, for example, if the user doesn’t input the currency symbol before/after the value. You might want to make more lenient parsing for example with regular expressions or a FSM.

To allow inputting only valid values, you can use either the
CSValidatedTextfield
or
MaskedTextField
.

Hi, Shaun!

I had a similar task in my project and seems like
AutoReplaceField
solved it for me with a great success. Maybe you also should try it. There are already classes for the numerical input and currency affairs. Hope it’ll help you.

Cool it looks like one of those options should probably work for me…

I’m having a problem however when trying to install UI addons with my application… I’m getting the following error when the page loads where the widget is supposed to be…

Widgetset does not contain implementation for org.vaadin.autoreplacefield.AutoReplaceField. Check its @ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:

I read up on the issue a bit but still am not entirely sure what I need to do to recompile the widgetset. Any advice on this? All I’ve done is add the dependency to my POM, I’m sure I’m just missing a step to get these things running.

I’ve got my project setup with maven and am running on jetty. All I’ve been doing to run my project is a mvn clean install jetty:run

You need to create your own widgetset (.gwt.xml file), update it to refer to the widgetsets from the add-ons you are using and then compile the widgetset. The widgetset needs to be updated when the set of client-side add-ons in your project changes, and also recompiled if you upgrade Vaadin in the project.

For instructions on how to do this with Maven, see e.g.
these instructions
. If you haven’t used recent versions of the Vaadin archetypes to create your project, you’ll need to copy some sections to your pom.xml (see the link from the instructions). Once everything is set up, it is a matter of running e.g. “mvn vaadin:update-widgetset gwt:compile package”.

If you don’t want the widgetset compilation to take place automatically but only when you explicitly ask for it, you can put the build related plugin configuration (Vaadin and GWT Maven plugins) in a dependencyManagement section. This can reduce build times as GWT compilation is quite slow.

Awesome thanks to everybody for helping out.

However with those instructions if the

widgetset com.example.myapp.widgetset.MyAppWidgetSet

isn’t within your servlet tag in your web.xml the instructions didn’t work for me. Once I realized I had it in the wrong spot all of this worked quite well. Thanks.