This project helps with generating binding classes from wicket templates and translation keys via annotation processing for compile time consistency checking.
It has been inspired by bindgen.
Java 1.6 compiler (for service provider support).
- joist util 0.5 - http://joist.ws/codeGeneration.html.
- slf4j (required by joist)
Just drop the jar including its dependencies onto your classpath.
Annotate your wicket component classes with the @HasTemplate
annotation if
they define a template and with the @HasTranslation
annotation if they define
a translation file.
Put a file named "wicket-id-bindings-generator.properties" in your project home. In it you can configure the following properties:
source folders
- the comma separated paths to search for the wicket templates and translation files relative to the properties file. E.g. if your templates are right next to your java files in src/main/java, then configure it with src/main/java. If this property is unset, the generator will look right next to the built class files, which is probably not what you want.source.encoding
- the default encoding to use for reading the templates, defaults toUTF-8
.template.enabled
- enable the generation of template bindings, defaults totrue
.template.extension
- the file extension of the templates, defaults tohtml
.template.bindingsuffix
- a suffix appended to the generated bindings, defaults toWID
. If e.g. there is a wicket component with a template and the nameMyPage
, the generated binding will be generated in the package of the component with the nameMyPageWID
.translation.enabled
- enable the generation of translation bindings, defaults totrue
.translation.bindingsuffix
- a suffix appended to the generated bindings, defaults toI18N
.translation.type
- the file types of the translation files. Can be eitherxml
orproperties
, defaults toproperties
.- XML files are expected to end with
.properties.xml
, which is the default setting since Wicket 1.5. If you need support for the older.xml
extension check out the previous version.
- XML files are expected to end with
debug
- if set totrue
, debug messages are logged while processing.
A sane minimal properties file probably looks like this:
template.folders=src/main/java
You can configure Eclipse so that the bindings are generated whenever you save changes in your wicket components annotated with either one of the annotations.
Go to Project Properties -> Java Compiler -> Annotation Processing
and
enable annotation processing. Then, under Factory Path
, add the generator
jar plus its dependencies. Click the Advanced button to make sure the processors
are recognized by eclipse.
In order to generate the jar, use maven:
mvn package