[Tapestry4] 请教级连显示的问题
163
2007-01-30
刚刚遇到的问题
有两个列表<select>A,B 列表A:显示大类名称 列表B:显示小类名称 两个列表数据均从数据库取出得到. 效果:当改变(选择)列表A中大类时候.列表B中相应列出此大类的小类名称. 这个功能不是很难.以前做法可以用JAVASCRIPT做级连显示...可是现在用到trapestry了。有点不知道如何结合~~~ 做法: 1.把大类信息从数据库里取出.封装到BigClassModel里.小类信息取出,封装到SmallClassModel里. 2.用trapestry里的propertySelect组件.分别在列表A,B中显示大类及小类的名称. 3...问题是????任何调用一个方法.使点击大类时候.小类列表跟随着变化呢??????? 请教各位了.... |
|
tapestry
2007-01-31
Form组件定义
<form jwcid="@Form" delegate="bean:delegate" clientValidationEnabled="true" refresh="listener:onRefresh"> PropertySelection组件定义 <span jwcid="category@PropertySelection" model="ognl:categorySelectionModel" value="ognl:categoryId" validators="validators:required" displayName="父类别" class="input_text" onchange="javascript:this.form.events.refresh();"/> <span jwcid="subCategory@PropertySelection" model="ognl:subCategorySelectionModel" value="ognl:subCategoryId" validators="validators:required" displayName="子类别" class="input_text"/> java类中如下 public IPropertySelectionModel getCategorySelectionModel() { return new NameIdentitySelectionModel(getCategoryService() .getRootCategorys(0, -1)); } @Persist("session") public abstract Long getCategoryId(); public abstract void setSubCategorySelectionModel( IPropertySelectionModel selectionModel); public abstract Long getSubCategoryId(); public void pageBeginRender(PageEvent event) { IPropertySelectionModel subModel = null; if (getCategoryId() == null) { Set<Category> subCategorys = getCategoryService().getRootCategorys( 0, 1).get(0).getSubCategorys(); subModel = new NameIdentitySelectionModel(new ArrayList<Category>( subCategorys)); } else { Set<Category> subCategorys = getCategoryService().findByID( getCategoryId()).getSubCategorys(); subModel = new NameIdentitySelectionModel(new ArrayList<Category>( subCategorys)); } setSubCategorySelectionModel(subModel); } public ILink onRefresh() { //其他处理 return getPageService().getLink(false, getPageName()); } 如果没有指定父目录,默认为第一个子目录。 |
|
163
2007-01-31
感谢您的回复:)
学习中..... 你的意思是通过选择大类的ID把子类的信息封装到小类模型里.并放入List里,然后更新小类模型,并刷新页面是吧~~~~ |
|
pppppp
2007-02-02
用4.1的ajax很容易实现
|