我的表单上有一个Dojo名称文本框“xe:djextNameTextBox”。单击[x],将从列表中删除名称。如何在不解析getComponent(“myNameBox”)中的所有值的情况下检查删除或单击的确切名称.getValue()?
答案 0 :(得分:0)
在我看来,处理此问题的唯一方法是解析所有值以获取确切删除名称的信息。我不得不在之前的项目中处理同样的问题。
设置viewScope var“viewFiltersAsString”:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:log('beforerenderresponse (start rendering)');
requestScope.start = new Date().getTime();
viewScope.put('viewFiltersAsString', viewController.getViewFiltersAsString());
viewController.actionSetPage();}]]></xp:this.beforeRenderResponse>
扩展库Dojo名称列表文本框控件:
<xe:djextListTextBox id="djFilters" multipleSeparator=","
value="#{viewScope.viewFiltersAsString}" displayLabel="true"
title="Hier klicken um Filter zu löschen">
<xe:this.dataProvider>
<xe:simpleValuePicker caseInsensitive="false"
labelSeparator="~" valueListSeparator=","
valueList="#{viewController.viewFiltersLabelsAsString}">
</xe:simpleValuePicker>
</xe:this.dataProvider>
<xp:eventHandler event="onChange" submit="true" refreshMode="partial"
refreshId="${javascript:compositeData.refreshId}" execMode="partial"
action="#{javascript:viewController.setViewFiltersAsString(@Trim(viewScope.get('viewFiltersAsString')).toString())}">
</xp:eventHandler>
</xe:djextListTextBox>
/**
* Converts all filters to a useable format for dojo List Textbox
* @return string of filters
*/
public String getViewFiltersAsString() {
String filtersAsString = "";
for (ViewFilter filter : viewFilters) {
if (filtersAsString == "") filtersAsString = filter.getKey();
else filtersAsString += "," + filter.getKey();
}
return filtersAsString;
}
public void setViewFiltersAsString(String viewFiltersAsString) {
if (viewFiltersAsString != null && !viewFiltersAsString.equals("")) {
List<String> currentfilters = Converter.toList(",", viewFiltersAsString);
for (ViewFilter filter : viewFilters) {
boolean remove = true;
for (String currentFilter : currentfilters) {
if (filter.getKey().equals(currentFilter)) {
remove = false;
break;
}
}
if (remove) {
// user can click only one filter at one time
setActionViewFilter(viewFilters.removeFilter(filter));
break;
}
}
} else {
setActionViewFilter(viewFilters.removeFilter(viewFilters.get(0)));
}
}
提示:viewFilters
是java.util.List
ViewFilter
个对象,ViewFilter是一个简单的java类,包含有关过滤器的信息(在您的情况下是名称)