浏览 4273 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-02-12
HTML代码:
页面类如下,
java 代码
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-02-12
终于知道怎么用了,现分享一下;
import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import org.apache.tapestry.dojo.form.DefaultAutocompleteModel; import org.apache.tapestry.dojo.form.IAutocompleteModel; import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; import org.apache.tapestry.html.BasePage; public abstract class AutoCompleter extends BasePage implements PageBeginRenderListener { public Date date = null; public IAutocompleteModel model = null; public void pageBeginRender(PageEvent arg0) { setText("TEXT"); setDate(new Date()); } public IAutocompleteModel getModel() { if (model == null) { List values = new ArrayList(); SimpleBean s1 = new SimpleBean(new Integer(1), "Simple 1", 100); SimpleBean s2 = new SimpleBean(new Integer(2), "Simple 2", 200); SimpleBean s3 = new SimpleBean(new Integer(3), "Simple 3", 300); values.add(s1); values.add(s2); values.add(s3); model = new DefaultAutocompleteModel(values, "id", "label"); } return model; } public abstract void setText(String text); public abstract String getText(); public abstract SimpleBean getSelect(); public void formSubmit() { System.out.println(getDate()); System.out.println(getSelect().getValue()); } public void setDate(Date d) { if(date == null) { this.date = new java.util.Date(); } else { this.date = d; } } public abstract Date getDate(); } package autoCompleter.test; public class SimpleBean { private Integer _id; private String _label; private int _value; public SimpleBean(Integer id, String label, int value) { _id = id; _label = label; _value = value; } /** * @return the id */ public Integer getId() { return _id; } /** * @return the label */ public String getLabel() { return _label; } /** * Returns the value stored. * * @return The value stored. */ public int getValue() { return _value; } /** * {@inheritDoc} */ @Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((_id == null) ? 0 : _id.hashCode()); return result; } /** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final SimpleBean other = (SimpleBean) obj; if (_id == null) { if (other._id != null) return false; } else if (!_id.equals(other._id)) return false; return true; } } |
|
返回顶楼 | |
发表时间:2007-02-12
发觉这个autocomplete的显示速度超慢
|
|
返回顶楼 | |
发表时间:2007-09-07
请问楼主,为什么我复制你的代码,运行后并没有看到列表显示的内容,而且一输入就会在列表框下面显示以下信息:
DEBUG: please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints 楼主能不能告诉我是哪里出问题了,可以的话,autocomplete的用法原理也一并解释一下,看了源码,理解了一点点...谢谢! |
|
返回顶楼 | |