在检票口中使用调色板模型的自动完成功能

发布于 2024-12-17 15:19:02 字数 28 浏览 0 评论 0原文

检票口是否有可能使调色板充当自动完成功能?

Is there any possibility in wicket to make a palette acting as auto-complete?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2024-12-24 15:19:02

愚蠢,是的,你可以,这很困难,我几个月前就做到了,它没有完全相同的代码,但希望有所帮助:

你需要一个表单来提交你正在搜索的字段,然后修改模型,最后重新绘制你需要的

原始类用西班牙语写的,对任何奇怪的事情表示抱歉: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);

}

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);

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文