在Autocompletetextfield使用面板,而不是字符串 [英] Using panels instead of String in Autocompletetextfield

查看:261
本文介绍了在Autocompletetextfield使用面板,而不是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的检票,以建立一个网站上的搜索引擎的用户界面。当用户正在输入的结果示于下拉。由于我有很多不同的对象(每个不同的显示结构)我想定义多个面板。因此,对于在db每个找到的项目,它得到正确的面板和右结构。因此,例如:如果找到的搜索引擎用户,它应该只显示名称。当图片被发现,缩略图和说明等...

I am using Wicket to build an ui for a searchengine on a website. As the user is typing the results are shown in a dropdown. As I have a lot of different objects (with each a different display structure) I want to define several panels. So for each found item in the db, it gets the right panel and right structure. So for example : if the searchengine finds a user, it should show only name. When a picture is found, a thumbnail and a description, etc...

现在我使用的是AutocompleteTextField但是只需要字符串。我想到了在字符串中添加HTML并显示它这样。但因为这是不是一个真正的干净的解决方案,我想用面板。

Right now I am using the AutocompleteTextField but it only takes strings. I thought about adding html in the string and show it like that. But as that is not really a clean solution, I am thinking of using panels.

所以,谁知道怎么用的面板,而不是字符串在AutoCompleteTextField?

So, anyone know how I can use panels instead of the strings in a AutoCompleteTextField?

推荐答案

创建自己的组件。使用一个ListView,把它变成一个WebMarkupContainer。显示了基于TextField的输入WebMarkupContainer和刷新连接到文本字段中OnChangeAjaxBehavior ListView控件。

Create your own Component. Use a ListView, put it into a WebMarkupContainer. Show the WebMarkupContainer based on the TextField input and refresh the ListView in the OnChangeAjaxBehavior attached to the TextField.

这种方式你了你想达到什么的完全控制。

This way you have full control over what you want to achieve.

举例code为ListView:

Example code for the ListView:

   private ListView getLv(){
      ListView lv = new ListView(PANEL, new PropertyModel(this, "someList")) {
         @Override
         protected void populateItem(ListItem item) {
            Integer type = item.getModelObject().getType();
            if (type == 1) {
               item.add(new PanelType1("panel", item.getModelObject().someIdMaybe));
            } else if (type == 2) {
               item.add(new PanelType2("panel", item.getModelObject().someIdMaybe));
            }
         }
      };
      return lv;
   }

这篇关于在Autocompletetextfield使用面板,而不是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆