`

GWT:增加remote框+回车监听

 
阅读更多
//排序(1)=进入页面,排序(2)=初始化 远程框,排序(3)=准备调用后台方法,
//排序(4)=调用后台方法,排序(5)=执行后台方法,获取客户对象,反馈客户编码,
//排序(6)=后台方法处理完毕,如果正确进入此方法,并将后台数据保存在custorCode字段,
//排序(7)=根据6发送的消息判断是否相等,相等对customerLabelTextUI控件赋值

//MaintainFirstPackageCheckPage.java
public class MaintainFirstPackageCheckPage extends 
	BaseCustomMaintainTemplate implements IsSerializable{
	//包装数量采集面板
	private transient ScaningPanel scaningPanel;
	//排序(1)
	public void draw(com.gwtext.client.widgets.Panel content) {
		scaningPanel = new ScaningPanel(this, "ScaningPanel");
		container.add(scaningPanel, new RowLayoutData("8%"));
	}
	//排序(7)
	public void doDispath(String message){
		if (message.equals("MSG_CUSTOR_CODE")) {
			scaningPanel.customerLabelTextUI.setValue
				(PackagingDataAccessor.custorCode);
		}
	}
}
//ScaningPanel.java
public class ScaningPanel extends AbstractSupportPanel{
	//客户编码
	private transient TextUI customerLabelTextUI;
	//远程框
	private transient CustomRemoteUI customerLabelRemoteUI;//yc min
	//排序(2)
	protected void draw() {
			String pageName = "MaintainFirstPackageCheckPage.";
			String custerHql = "SELECT company.id,company.code,company.name"+
					 " FROM WmsOrganization company"+
					 " WHERE company.status = 'ENABLED'"+
					 " AND company.beCustomer = true" +
					 " AND company.subjectionWarehouse =#{SESSION_WAREHOUSE}"+
					 " AND (company.code  LIKE :param OR company.name LIKE :param)";
			customerLabelRemoteUI = com.vtradex.wms.client.ui.UIFactory.
				createStandardRemoteUI(pageName + "customerLabelRemoteUI", 
					custerHql, false, true, 1, 180, 3, "序号,编码,名称");
			customerLabelRemoteUI.setRemoteUIConfig(com.vtradex.wms.client.ui.
				UIFactory.createRemoteUIConfig(
					com.vtradex.wms.client.ui.UIFactory.
						createTextUIConfig(pageName + "customerLabelRemoteUI")));
			customerLabelRemoteUI.setRow(1);
			customerLabelRemoteUI.setColumn(4);
			customerLabelRemoteUI.addToTable(formTable);
			customerLabelRemoteUI.setFocusUI(Boolean.TRUE);
			TextBox tb = customerLabelRemoteUI.getTextBox();
			tb.addKeyboardListener(new KeyboardListener() {//增加监听
				public void onKeyDown(Widget sender, char keyCode, int modifiers) {
				}
				public void onKeyPress(Widget sender, char keyCode,
						int modifiers) {
					initInfo(customerLabelRemoteUI.getValue());
					
					if(StringUtils.isEmpty((String)customerLabelTextUI.getValue())){
						showMessage("客户编码不能为空", Boolean.FALSE);
					}else{
						getCheckInfoByItemAndCustomer();
					}
				}
				public void onKeyUp(Widget sender, char keyCode, int modifiers) {
					initInfo(customerLabelRemoteUI.getValue());
				}			
			});
			
			customerLabelTextUI = UIFactory.createTextUI("客户编码", true, true, 1,180);
			customerLabelTextUI.setRow(1);
			customerLabelTextUI.setColumn(5);
			customerLabelTextUI.addToTable(formTable);
			customerLabelTextUI.setVisible(Boolean.FALSE);
			((TextBox)customerLabelTextUI.getInputWidget()).
				addKeyboardListener(new KeyboardListener() {		
				public void onKeyUp(Widget sender, char keyCode, int modifiers) {
					if(KeyboardListener.KEY_ENTER == keyCode){
						if(StringUtils.isEmpty((String)customerLabelTextUI.getValue())){
							showMessage("客户编码不能为空", Boolean.FALSE);
						}else{
							getCheckInfoByItemAndCustomer();
						}						
					}				
				}
				public void onKeyPress(Widget sender, 
					char keyCode, int modifiers) {
				}			
				public void onKeyDown(Widget sender, 
					char keyCode, int modifiers) {		
				}
			});
	}
	
	/**
	 * 获取作业指导和高关注
	 */
	public void getCheckInfoByItemAndCustomer(){
		Map parameterMap = new HashMap();
		parameterMap.put(PackagingConstants.KEY_ITEM_LABEL,
			itemLabelTextUI.getValue().toString().trim().toUpperCase());
		parameterMap.put(PackagingConstants.KEY_CUSTOMER_LABEL, 
				customerLabelTextUI.getValue().toString().trim().toUpperCase());
		MaintainFirstPackageCheckPage.this.getData().
			getCheckInfoByItemAndCustomer(parameterMap);
	}
	//排序(3)
	public void initInfo(Object object){
		if(object != null){
			if(isNUllOREmpty(object.toString())){
				return;
			}
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("custorId",object.toString());
		MaintainFirstPackageCheckPage.this.getData().getCustorCode(map);
	}
	private boolean isNUllOREmpty(String str){
		if(str==null || str.equals("")){
			return true;
		}
		return false;
	}
	
	public PackagingDataAccessor getData() {
		return (PackagingDataAccessor)super.getData();
		
	}
}

//PackagingDataAccessor.java
public class PackagingDataAccessor extends 
	BaseCustomMaintainTemplate implements IsSerializable{
	
	public static String custorCode;
	//排序(4)
	/**获取客户code yc min*/
	public void getCustorCode(Map params){
		//String message,String managerName,String methodName,Map params
		this.remoteCall("MSG_CUSTOR_CODE", "pcFirstPackageManager", 
			"getCustorCode", params);
	}
	//排序(6)PackagingDataAccessor
	public void onSuccess(String message, Map result) {
		if(message.equals("MSG_CUSTOR_CODE")){
			custorCode = (String) result.get("custorCode");
			this.sendMessage("MSG_CUSTOR_CODE");
		}
	}
}

//排序(5)
//pcFirstPackageManager
public class DefaultPCFirstPackageManager extends DefaultBaseManager 
	implements PCFirstPackageManager {
	public Map getCustorCode(Map params){
		Map<String,String> result = new HashMap<String, String>();
		if(params.get("custorId")==null){
			return null;
		}
		try {
			Long custorId = Long.parseLong((String)params.get("custorId"));
			WmsOrganization company = commonDao.load
				(WmsOrganization.class, custorId);
			if(company==null){
				return null;
			}
			result.put("custorCode", company.getCode());
		} catch (Exception e) {
			return null;
		}
		return result;
	}
}

 

 

  • 大小: 48.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics