在wicket中是否有可能使调色板充当自动完成?
dumb, yes you can its quiet difficult, i did it months ago its no exactly the same code but hope helps:
you need a form for submit the field where you are searching, then modify the models and finally redraw what you need
the original class is written in spanish sorry for any strange thing :S
public SearchPallete() {
currentMedics = database action
avaibleMedics = new LoadableDetachableModel<Collection<? extends YourModel>>() {
private static final long serialVersionUID = 1L;
private List<YourModel> res;
@Override
protected Collection<? extends YourModel> load() {
res = get from database list of avaibles;
res.addAll(add current assigned model);
return res;
}
};
//form for auto submit with ajax (it could be refactor)
ajaxFormPallet = new AjaxFormSubmitBehavior(palleteForm, "onchange") {
private static final long serialVersionUID = -4029493502490267181L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
}
@Override
protected void onError(AjaxRequestTarget target) {
}
};
IChoiceRenderer<YourModel> renderer = new ChoiceRenderer<YourModel>(
"field", "field");
pallete = new Palette<YourModel>("pallete",
currentMedics, avaibleMedics, renderer, 10, false) {
private static final long serialVersionUID = 1L;
protected Recorder<YourModel> newRecorderComponent() {
Recorder<YourModel> recorder = super
.newRecorderComponent();
recorder.add(ajaxFormPallet);
return recorder;
}
@Override
protected ResourceReference getCSS() {
return new PackageResourceReference(MedicosTratantesPage.class,
"theStyle");
}
};
//for ajax
pallete.setOutputMarkupId(true);
//pallete form
palleteForm = new Form<FormMedicosTratantesModel>("palleteForm") {
private static final long serialVersionUID = 5036201492891006829L;
@SuppressWarnings("unchecked")
protected void onSubmit() {
//search and submit stuff
}
};
searchField = new TextField<String>("Buscador", thethingToFind);
searchForm = new Form<String>("searchForm") {
private static final long serialVersionUID = 1L;
protected void onSubmit() {
pallete.detachModels();
}
};
searchForm.add(searchField);
searchField.add(new AjaxFormSubmitBehavior(searchForm, "onkeyup") {
private static final long serialVersionUID = 7939356732729920901L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
log.debug("searchField cambio");
target.add(pallete);
}
@Override
protected void onError(AjaxRequestTarget target) {
}
});
add(palleteForm);
add(searchForm);
palleteForm.add(pallete);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.