文通過幾個小例子來講解金蝶EAS BOS 開發F7控件的過濾使用;
1、新建一張業務單據,存在兩個F7控件,基本庫位屬於倉庫,只有選擇了倉庫才,能確定庫位。發布業務單元,如下:

2、打開JAVA視圖,找到EDITUI JAVA文件,新增方法
a)首先為倉庫添加過濾,prmtwarehouse為倉庫F7,並添加監聽事件。
private void initF7() {
EntityViewInfo entityView = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new
FilterItemInfo("number","A2%",CompareType.LIKE));
entityView.setFilter(filter);
prmtwarehouse.setEntityViewInfo(entityView);
prmtwarehouse.addDataChangeListener(new DataChangeListener() {
public void dataChanged(DataChangeEvent e) {
datachangeAction_dataChanged(e);
}
});
}
b)為庫位添加過濾,prmtlocationhouse為庫位F7;並根據F7是否存在可選項,進行必輸、默認值設置;
private void locationhouseF7(String warehouseid) {
EntityViewInfo entityView = locationhouseF7Judge(warehouseid);
prmtlocationhouse.setEntityViewInfo(entityView);
try {
LocationCollection local = LocationFactory.getRemoteInstance()
.getLocationCollection(entityView);
if (local.size() > 0) {
prmtlocationhouse.setRequired(true);
prmtlocationhouse.setValue(local.get(0));
} else {
prmtlocationhouse.setRequired(false);
}
} catch (BOSException e1) {
e1.printStackTrace();
}
}
private EntityViewInfo locationhouseF7Judge(String warehouseid) {
EntityViewInfo entityView = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(
new FilterItemInfo("WAREHOUSE.id", warehouseid,
CompareType.EQUALS));
entityView.setFilter(filter);
return entityView;
}
c)新增倉庫F7更新事件方法
public void datachangeAction_dataChanged(DataChangeEvent e) {
try {
Object source = e.getSource();
if ((e.getOldValue() != null)
&& (e.getOldValue().equals(e.getNewValue()))) {
return;
}
if (this.prmtwarehouse.equals(source)) {
if (e.getNewValue() == null) {
prmtlocationhouse.setValue(null);
locationhouseF7(null);
} else {
String warehouseid = ((WarehouseInfo) e.getNewValue())
.getId().toString();
prmtlocationhouse.setValue(null);
locationhouseF7(warehouseid);
}
}
} catch (Exception exc) {
handUIException(exc);
}
}
d)重寫verifyInput(ActionEvent e)方法進行必輸項驗證
@Override
protected void verifyInput(ActionEvent e) throws Exception {
EntityViewInfo entityView;
if(com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
.getWarehouse())){
entityView = locationhouseF7Judge(null);
}else{
entityView = locationhouseF7Judge(editData
.getWarehouse().getId().toString());
}
try {
LocationCollection local = LocationFactory.getRemoteInstance()
.getLocationCollection(entityView);
if (local.size() > 0) {
if (com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
.getLocationhouse())) {
throw new com.kingdee.eas.common.EASBizException(
com.kingdee.eas.common.EASBizException.CHECKBLANK,
new Object[] { "庫位" });
}
}
} catch (BOSException e1) {
e1.printStackTrace();
}
}
e)在EDITUI構造方法中調用創建的方法
public F7FilterEditUI() throws Exception {
super();
initF7();
locationhouseF7(null);
}
3、完成后,刷新啟動服務,即可實現F7動態級聯,並實現動態改必輸校驗。
-----------------------------------------
附加一個自定義Query小知識:只需要將需要重新綁定的Query,重新set一下就可以了。
private void initF7() {
this.prmtwarehouse.setQueryInfo("com.kingdee.eas.demo.f7.app.warehouseUserDefine");
。。。。。。
}
PS:自定義Query的一個注意事項,不能設置id不可見,不然選擇時,會提示報錯。

