Why the Vaadin not have a TextField mask natively? Is no better than an add-on?
http://digitalbush.com/projects/masked-input-plugin/#demo
You have to compile GWT to use add-ons…
Why the Vaadin not have a TextField mask natively? Is no better than an add-on?
http://digitalbush.com/projects/masked-input-plugin/#demo
You have to compile GWT to use add-ons…
Could be in the core, but I guess we’ve had other priorities Feel free to create a ticket, if not found in our issue tracker already.
The GWT compilation is just a one time thing (per add-on), so shouldn’t be that much trouble
Ok!
If only I had a Vaadin onKeyPress to make a mask.
But I thank you!
You already have that, on the client side using GWT. The new TextChangeEvent for TextFields might help you somewhat on the server, but having the event make a server roundtrip for each keystroke is not really efficient or responsive for the end user.
Ok, tanks!
So, I’m trying to create a custom component to use the onkeypress of GWT, but is not working:
My code:
File module XML for GWT: org.ici.ged.apresentacao.vaadin.widgetset.WidgedSet.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" />
</module>
File to client side: org.ici.ged.apresentacao.vaadin.widgetset.client.ui.VEntradaDeTexto.java:
package org.ici.ged.apresentacao.vaadin.widgetset.client.ui;
import com.vaadin.terminal.gwt.client.ui.*;
public class VEntradaDeTexto extends VTextField
{
public VEntradaDeTexto()
{
super();
}
}
File to server side: org.ici.ged.apresentacao.vaadin.comum.EntradaDeDados.java:
package org.ici.ged.apresentacao.vaadin.comum;
import org.ici.ged.apresentacao.vaadin.widgetset.client.ui.*;
import com.vaadin.data.validator.*;
import com.vaadin.ui.*;
@ClientWidget(VEntradaDeTexto.class)
public class EntradaDeDados extends TextField
{
public EntradaDeDados(String caption)
{
super(caption);
}
}
build.xml for compile GWT code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Compile Vaadin Widgetset" default="compile-widgetset" basedir=".">
<description>Compiles a combined widgetset of all Vaadin widgetsets found on the classpath.</description>
<!--
Important notice!!
This Ant script depends on the NetBeans project specific build-impl.xml
file. If you want to use this script in some other environment, you need
to manually create init and compile targets and define required properties.
See also http://demo.vaadin.com/docs/example-source/build-widgetset.xml
for another example script.
-->
<!-- import file="nbproject/build-impl.xml"/ -->
<target name="widgetset-init">
<!-- Name of the widget set -->
<property name="widgetset" value="org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet"/>
<!-- Path to the widgetset directory. Required only for -->
<!-- generated widget sets. Must be relative to -->
<!-- $src.dir, that is, under the first entry in -->
<!-- classpath. -->
<property name="widgetset-path" value="com/example/myapp/widgetset"/>
<!-- Target where to compile the widget set -->
<property name="client-side-destination" value="WebContent/VAADIN/widgetsets" />
<!-- Define if the widget set be generated automatically -->
<!-- from all widget sets included in the class path. -->
<property name="generate.widgetset" value="1"/>
</target>
<!-- Generates a combined widget set from all widget -->
<!-- sets in the class path, including project sources. -->
<!-- Updates the configuration if it already exists. -->
<target name="generate-widgetset" depends="widgetset-init" if="generate.widgetset">
<echo>Updating ${widgetset}...</echo>
<echo>Remember to define the widgetset in web.xml as follows.</echo>
<echo>
<init-param>
<param-name>widgetset</param-name>
<param-value>${widgetset}</param-value>
</init-param>
</echo>
<!-- Create the directory if it does not already exist. -->
<mkdir dir="${src.dir}/${widgetset-path}"/>
<java classname="com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder" failonerror="yes" fork="yes" maxmemory="256m">
<arg value="${widgetset}"/>
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<pathelement path="${javac.classpath}" />
<pathelement path="${build.web.dir}/WEB-INF/classes" />
<pathelement location="src" />
<pathelement location="WebContent/WEB-INF/classes" />
<fileset dir="WebContent/WEB-INF/lib" includes="**/*.jar" excludes="xmlparserv2.jar" />
</classpath>
</java>
</target>
<!-- Compiles the widget set using the GWT compiler. -->
<target name="compile-widgetset" depends="widgetset-init, generate-widgetset">
<echo>Compiling ${widgetset} into ${client-side-destination} directory...</echo>
<java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="256m">
<arg value="-war" />
<arg value="${client-side-destination}" />
<arg value="${widgetset}" />
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<pathelement path="${javac.classpath}" />
<pathelement path="${build.web.dir}/WEB-INF/classes" />
<pathelement location="src" />
<pathelement location="WebContent/WEB-INF/classes" />
<fileset dir="WebContent/WEB-INF/lib" includes="**/*.jar" excludes="xmlparserv2.jar" />
</classpath>
</java>
</target>
</project>
It compiles the code normally:
Buildfile: D:\work_eclipse\workspace_ged\cwb_desenvolvimento\compilar_vaadin.xml
widgetset-init:
generate-widgetset:
[echo]
Updating org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet...
[echo]
Remember to define the widgetset in web.xml as follows.
[echo]
[echo]
<init-param>
[echo]
<param-name>widgetset</param-name>
[echo]
<param-value>org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet</param-value>
[echo]
</init-param>
[echo]
[java]
17/02/2011 14:50:17 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[java]
INFO: Widgetsets found from classpath:
[java]
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:D:/work_eclipse/workspace_ged/cwb_desenvolvimento/WebContent/WEB-INF/lib/vaadin-6.5.0.jar!/
[java]
org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet in file://D/work_eclipse/workspace_ged/cwb_desenvolvimento/src
[java]
17/02/2011 14:50:17 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[java]
INFO: Search took 78ms
compile-widgetset:
[echo]
Compiling org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet into WebContent/VAADIN/widgetsets directory...
[java]
Compiling module org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet
[java]
Scanning for additional dependencies: jar:file:/D:/work_eclipse/workspace_ged/cwb_desenvolvimento/WebContent/WEB-INF/lib/vaadin-6.5.0.jar!/com/vaadin/terminal/gwt/client/WidgetSet.java
[java]
Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.WidgetMap'
[java]
Rebinding com.vaadin.terminal.gwt.client.WidgetMap
[java]
Invoking generator com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator
[java]
Detecting Vaadin components in classpath to generate WidgetMapImpl.java ...
[java]
17/02/2011 14:51:02 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
[java]
INFO: Searching for paintables..
[java]
17/02/2011 14:51:04 com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
[java]
INFO: Search took 1797ms
[java]
Widget set will contain implementations for following components:
[java]
com.vaadin.ui.AbsoluteLayout
[java]
com.vaadin.ui.Accordion
[java]
com.vaadin.ui.Button
[java]
com.vaadin.ui.CheckBox
[java]
com.vaadin.ui.ComboBox
[java]
com.vaadin.ui.CssLayout
[java]
com.vaadin.ui.CustomComponent
[java]
com.vaadin.ui.CustomLayout
[java]
com.vaadin.ui.DateField
[java]
com.vaadin.ui.DragAndDropWrapper
[java]
com.vaadin.ui.Embedded
[java]
com.vaadin.ui.Form
[java]
com.vaadin.ui.FormLayout
[java]
com.vaadin.ui.GridLayout
[java]
com.vaadin.ui.HorizontalLayout
[java]
com.vaadin.ui.HorizontalSplitPanel
[java]
com.vaadin.ui.InlineDateField
[java]
com.vaadin.ui.Label
[java]
com.vaadin.ui.Link
[java]
com.vaadin.ui.ListSelect
[java]
com.vaadin.ui.MenuBar
[java]
com.vaadin.ui.NativeButton
[java]
com.vaadin.ui.NativeSelect
[java]
com.vaadin.ui.OptionGroup
[java]
com.vaadin.ui.OrderedLayout
[java]
com.vaadin.ui.Panel
[java]
com.vaadin.ui.PasswordField
[java]
com.vaadin.ui.PopupView
[java]
com.vaadin.ui.ProgressIndicator
[java]
com.vaadin.ui.RichTextArea
[java]
com.vaadin.ui.Select
[java]
com.vaadin.ui.Slider
[java]
com.vaadin.ui.SplitPanel
[java]
com.vaadin.ui.TabSheet
[java]
com.vaadin.ui.Table
[java]
com.vaadin.ui.TextArea
[java]
com.vaadin.ui.TextField
[java]
com.vaadin.ui.Tree
[java]
com.vaadin.ui.TwinColSelect
[java]
com.vaadin.ui.Upload
[java]
com.vaadin.ui.UriFragmentUtility
[java]
com.vaadin.ui.VerticalLayout
[java]
com.vaadin.ui.VerticalSplitPanel
[java]
com.vaadin.ui.Window
[java]
Done. (2seconds)
[java]
Scanning for additional dependencies: jar:file:/D:/work_eclipse/workspace_ged/cwb_desenvolvimento/WebContent/WEB-INF/lib/vaadin-6.5.0.jar!/com/vaadin/terminal/gwt/client/ui/dd/VAcceptCriteria.java
[java]
Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory'
[java]
Rebinding com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory
[java]
Invoking generator com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator
[java]
Detecting available criteria ...
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.And
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget
[java]
creating mapping for com.vaadin.ui.Table.TableDropCriterion
[java]
creating mapping for com.vaadin.ui.Tree.TreeDropCriterion
[java]
creating mapping for com.vaadin.ui.Tree.TargetInSubtree
[java]
creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs
[java]
creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.Or
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.Not
[java]
Done. (0seconds)
[java]
Compiling 1 permutation
[java]
Compiling permutation 0...
[java]
Compile of permutations succeeded
[java]
Linking into D:\work_eclipse\workspace_ged\cwb_desenvolvimento\WebContent\VAADIN\widgetsets\org.ici.ged.apresentacao.vaadin.widgetset.WidgetSet
[java]
Link succeeded
[java]
Compilation succeeded -- 108,812s
BUILD SUCCESSFUL
Total time: 1 minute 56 seconds
But, in the browser:
Widgetset does not contain implementation for org.ici.ged.apresentacao.vaadin.comum.EntradaDeDados. 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:
org.ici.ged.apresentacao.vaadin.comum.EntradaDeDados(NO CLIENT IMPLEMENTATION FOUND)
The mask add-on work normally.
Any idea?
Tanks!
Make sure that your web.xml descriptor refers to the correct widget set (org.ici.ged.apresentacao.vaadin.widgetset.WidgedSet)
Or if your widget is bundled as an add-on and imported to your “real” project, make sure that the widgetset is built correctly in your project and that the web.xml in the project contains the correct widget set reference.
HTH,
/Jonatan
A solved my problem using the build-widgetset.xml example in the WebContent/docs/example-source/ of the Vaadin.
Chapter 10.8.4 of the Book of Vaadin:
Tanks!
[java]
Widget set will contain implementations for following components:
[java]
com.vaadin.ui.AbsoluteLayout
[java]
com.vaadin.ui.Accordion
[java]
com.vaadin.ui.Button
[java]
com.vaadin.ui.CheckBox
[java]
com.vaadin.ui.ComboBox
[java]
com.vaadin.ui.CssLayout
[java]
com.vaadin.ui.CustomComponent
[java]
com.vaadin.ui.CustomLayout
[java]
com.vaadin.ui.DateField
[java]
com.vaadin.ui.DragAndDropWrapper
[java]
com.vaadin.ui.Embedded
[java]
com.vaadin.ui.Form
[java]
com.vaadin.ui.FormLayout
[java]
com.vaadin.ui.GridLayout
[java]
com.vaadin.ui.HorizontalLayout
[java]
com.vaadin.ui.HorizontalSplitPanel
[java]
com.vaadin.ui.InlineDateField
[java]
com.vaadin.ui.Label
[java]
com.vaadin.ui.Link
[java]
com.vaadin.ui.ListSelect
[java]
com.vaadin.ui.MenuBar
[java]
com.vaadin.ui.NativeButton
[java]
com.vaadin.ui.NativeSelect
[java]
com.vaadin.ui.OptionGroup
[java]
com.vaadin.ui.OrderedLayout
[java]
com.vaadin.ui.Panel
[java]
com.vaadin.ui.PasswordField
[java]
com.vaadin.ui.PopupView
[java]
com.vaadin.ui.ProgressIndicator
[java]
com.vaadin.ui.RichTextArea
[java]
com.vaadin.ui.Select
[java]
com.vaadin.ui.Slider
[java]
com.vaadin.ui.SplitPanel
[java]
com.vaadin.ui.TabSheet
[java]
com.vaadin.ui.Table
[java]
com.vaadin.ui.TextArea
[java]
com.vaadin.ui.TextField
[java]
com.vaadin.ui.Tree
[java]
com.vaadin.ui.TwinColSelect
[java]
com.vaadin.ui.Upload
[java]
com.vaadin.ui.UriFragmentUtility
[java]
com.vaadin.ui.VerticalLayout
[java]
com.vaadin.ui.VerticalSplitPanel
[java]
com.vaadin.ui.Window
[java]
[b]
org.ici.ged.apresentacao.vaadin.comum.EntradaDeDados
[/b]