We are now a github organisation. You are invited to participate.
custom wicket extensions which might be useful
- my experiences are different from those of other - and these extensions are build with my experiences
- may be this is usefull for others, may be not at all
Stable (Maven Central Repository, Released: 09.10.2015 - wait 24hrs for maven central)
<dependency>
<groupId>de.flapdoodle.wicket7</groupId>
<artifactId>de.flapdoodle.wicket</artifactId>
<version>7.0.1</version>
</dependency>
Snapshots (Repository http://oss.sonatype.org/content/repositories/snapshots)
<dependency>
<groupId>de.flapdoodle.wicket7</groupId>
<artifactId>de.flapdoodle.wicket</artifactId>
<version>7.0.2-SNAPSHOT</version>
</dependency>
There are currently one module - models, which provides some model stuff. You must not include this wicket library at whole. Use can use only parts. You can use the model stuff with this dependency declaration replacing /*moduleIdGoesHere*/ with models and the right version (i think you get the pattern):
<dependency>
<groupId>de.flapdoodle.wicket6</groupId>
<artifactId>de.flapdoodle.wicket--/*moduleIdGoesHere*/</artifactId>
<version>/*see above for the right one here*/</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.wicket6</groupId>
<artifactId>de.flapdoodle.wicket--models</artifactId>
<version>/*see above for the right one here*/</version>
</dependency>
- init release based on 6.13.3
- works with wicket 7.0.0
Any model used as source model for a model transformation are detached if the transformating model ist detached. Any transformation evaluation is only done once as in LoadableDetachedModel.
public IModel<Integer> createSumModel(IModel<List<Integer>> source) {
return Models.on(source).apply(new Function1<Integer, List<Integer>>() {
@Override
public Integer apply(List<Integer> values) {
int sum=0;
for (Integer v : values!=null ? values : new ArrayList<Integer>()) {
if (v!=null) sum=sum+v;
}
return sum;
}
});
}
public <T> IModel<List<T>> subListModel(IModel<List<T>> source,IModel<Integer> offsetModel, IModel<Integer> sizeModel) {
IModel<List<T>> emptyIfNull = Models.emptyIfNull(source);
return Models.on(emptyIfNull,offsetModel,sizeModel).apply(new Function3<List<T>, List<T>, Integer, Integer>() {
@Override
public List<T> apply(List<T> list, Integer offset, Integer size) {
int startIdx=Math.min(list.size(), offset);
int lastIdx=Math.min(list.size(),offset+size);
return list.subList(startIdx, lastIdx);
}
});
}
A model is read only if setObject can not be used. But if you can change the content of the model value, the model is not unmodifiable. Its not the best idea to change a model value so there are some functions to prevent this.
List<Integer> source=new ArrayList<Integer>(Arrays.asList(1,2,3));
IModel<List<Integer>> unmodifiableListModel = Models.unmodifiable(source);
IModel<List<? extends Integer>> modifiableListModel = Model.ofList(Arrays.asList(1,2,3));
IModel<List<Integer>> asUnmodifiableListModel = Models.unmodifiable(modifiableListModel);
IModel<List<? extends Integer>> readOnlyListModel = Models.readOnly(modifiableListModel);