nc65重写保存前事件,利用递归,使字段输入值不为空

import java.awt.event.ActionEvent;

import nc.ui.pub.beans.MessageDialog;
import nc.ui.pubapp.uif2app.actions.pflow.SaveScriptAction;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.ui.uif2.editor.IEditor;
import nc.utils.ebiding.jyh901.GetNumbsUtil;

/**
 * @author dch
 *保存前事件:
 *冲红原因不为空,设置冲红状态为Y
 */
public class BeforeSaveAction extends SaveScriptAction {

    private IEditor editor;
    
    public IEditor getEditor() {
        return editor;
    }
    public void setEditor(IEditor editor) {
        this.editor = editor;
    }

    public void doAction(ActionEvent e) throws Exception {
        super.setEditor(this.editor);
        ShowUpableBillForm bill = (ShowUpableBillForm) getEditor();
        
        //获取冲红原因的内容,不为空,
        //否则,不允许保存
        String reason = bill.getBillCardPanel().getHeadItem("red_reason").getValue();
        String rea = reaNotNull(reason);
        bill.getBillCardPanel().getHeadItem("red_reason").setValue(rea);
        
        super.doAction(e);
    }
    


    public String reaNotNull(String reason){
        Object value=MessageDialog.showInputDlg(null, "提示", "请输入冲红原因", "业务错误");
        String rea = String.valueOf(value);
        if("".equals(rea) || rea==null || "null".equals(rea)){    //弹出框点击取消按钮,rea='null'
            return reaNotNull(rea);
        }else{
            return rea;
        }
    }
    
}

你可能感兴趣的:(UAP平台,Java)