当我第一次加载页面时,下拉选项中的默认选项是"选择一个".有没有办法将它保留在下拉列表中,即使我选择了一个选项?
(如果我想稍后放)
我有一个DropDownChoice如下:
final DropDownChoice<Term> terms = new DropDownChoice("terms", new Model<Term>(), new Model(new ArrayList(termDao.findAll())), new IChoiceRenderer<Term>() {
public Object getDisplayValue(Term object) {
return object.getIdentifier();
}
public String getIdValue(Term object, int index) {
return object.getId().toString();
}
});
Run Code Online (Sandbox Code Playgroud)
我想要"全选"而不是"选择一个".我怎样才能做到这一点?
我有很多DropDownChoice组件,表单中有很多项目,在加载表单时,我只想显示已保存的选定选项.当用户点击DropDownChoice时,我想动态地加载完整的项目列表.
可以这样做吗?
我有一个DropDownChoice的问题.我必须预先选择一个项目,但我找到的每个教程和示例,只考虑一个基本类型的列表.
我有一个Object列表.
class myObject {
private String name;
private String surname;
[setter and getter]
}
Run Code Online (Sandbox Code Playgroud)
在其他课堂上
List<MyObject> myList = some_data_retrieve();
MyObject defaultValue = some_simple_data_retrieve();
Run Code Online (Sandbox Code Playgroud)
使用以下构造器构建DropDownChoice:
final DropDownChoice<T> ddc = new DropDownChoice<T>(id, data, new ChoiceRenderer<T>(choiceRendererExpression, choiceRendererIdExpression));
Run Code Online (Sandbox Code Playgroud)
通过这种方式:
final DropDownChoice<myObject> ddc = new DropDownChoice<myObject>("wicket_id", myList, new ChoiceRenderer<myObject>("name", "surname"));
Run Code Online (Sandbox Code Playgroud)
现在.在每个教程/示例中,他们使用另一个带有Model的构造函数.例如:
private static final List<String> SEARCH_ENGINES = Arrays.asList(new String[] {
"Google", "Bing", "Baidu" });
private String selected = "Google";
DropDownChoice<String> listSites = new DropDownChoice<String>(
"sites", new PropertyModel<String>(this, "selected"), SEARCH_ENGINES);
Run Code Online (Sandbox Code Playgroud)
我试过这样的事情来模仿那种电话:
final DropDownChoice<myObject> ddc = …
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我有50多个表单,它们大多是彼此相似的并使用相同的DropDownChoice
组件.我可以创建单独的Panel
,我定义我的DropDownChoice
,然后我将以Panel
另一种形式使用它吗?否则,我如何实现这种情况?
例如
form1
有下一个字段:
name(TextField
)
surname(TextField
)
city(DropDownChoice
)
form2
有下一个字段:
Code(TextField
)
Amount(TextField
)
city(再次相同DropDownChoice
)
我想为这种方法做出漂亮的解决方案.
在Wicket中有什么东西可以做两个下拉选项,这样第一个doprdownchoice的第一个选择会改变第二个选项的所有选项吗?
任何人都可以告诉我,为什么这个来源
List<Data> datas = ~getData();
PropertyListView<Data> listView =
new PropertyListView<Data>("listView", new PropertyModel<List<Data>>(this, "datas")){
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<Data> item) {
Data data = item.getModelObject();
item.add(new MultiLineLabel("textLabel", data.getText());
@SuppressWarnings("unchecked")
ArrayList<DataParam> params = (ArrayList<DataParam>) ~getParamsForData(data);
DropDownChoice<DataParam> dropDownChoice =
new DropDownChoice<DataParam>("choiceSelector", new Model<ArrayList<DataParam>>(params), new ChoiceRenderer<Object>("key", "value")){
private static final long serialVersionUID = 1L;
@Override
protected boolean wantOnSelectionChangedNotifications(){
return true;
}
@Override
protected void onSelectionChanged(DataParam newSelection) {
super.onSelectionChanged(newSelection);
}
};
item.add(dropDownChoice);
}
};
public static final class …
Run Code Online (Sandbox Code Playgroud) 我有两个下拉选项,从第一个下拉选项中选择值后,我需要
从数据库表中选择相关值列表,并将此列表添加到第二个
下拉选项中.这是我的示例代码供参考.
给我任何提示或参考.
HTML:
<select wicket:id="DDCStartDate" style=" width : 98px;"></select>
<select wicket:id="DDCEndDate" style=" width : 98px;">.
Run Code Online (Sandbox Code Playgroud)
Java代码:
final DropDownChoice DDCStartDate=new DropDownChoice("DDCStartDate",new
PropertyModel(collectionReportModel, "DDCStartDate"),lst);
add(DDCStartDate);
DDCStartDate.setOutputMarkupId(true);
final DropDownChoice DDCEndDate=new DropDownChoice("DDCEndDate",);
add(DDCEndDate);
DDCEndDate.setOutputMarkupId(true);
Run Code Online (Sandbox Code Playgroud)
POJO代码:
private Date DDCStartDate;
private Date DDCEndDate;
public Date getDDCStartDate()
{
return DDCStartDate;
}
public void setDDCStartDate(Date dDCStartDate)
{
DDCStartDate = dDCStartDate;
}
public Date getDDCEndDate() {
return DDCEndDate;
}
public void setDDCEndDate(Date dDCEndDate) {
DDCEndDate = dDCEndDate;
}
Run Code Online (Sandbox Code Playgroud) 在我的DropDownChoice
我想要显示两个字段:名称 - 姓氏
DropDownChoice<Person> customer = new DropDownChoice<Person>(
"customer", new PropertyModel<Person>(customermodel, "customer"),list, new ChoiceRenderer<Person>("name", "id"));
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做?喜欢:彼得 - 格里芬