(cubasdoc.getLockpks(),
}
cubasdoc.getUserid(), \
// 更新 if (islock) { } // 异常 else { }
throw new nc.vo.pub.BusinessException try { }
getCubasdocDMO().updateForEx(cubasdoc); // 释放锁
PKLock.getInstance().releaseBatchLock
cubasdoc.getUserid(), \
} finally {
(cubasdoc.getLockpks(),
(nc.vo.bd.BDMsg.MSG_LOCKED());
1.8.3 附件管理功能实现
import java.awt.Container; import java.awt.Frame; import java.io.File; import nc.ui.ml.NCLangRes;
import nc.ui.pub.beans.MessageDialog; import nc.ui.pub.beans.UIFileChooser; import nc.ui.pub.beans.util.NCOptionPane; import nc.ui.pub.filemanager.FileManagerDialog; import nc.ui.pub.filemanager.FileManagerUtil; @SuppressWarnings(\
public class MyFileManagerDialog extends FileManagerDialog {
private int iMaxAttachmentSize = 5 * 1024 * 1024;// 上传附件的大小限制在5M private int iMaxCount = 5; //上传附件的个数限制在5个 //构造函数
public MyFileManagerDialog() { super(); }
public MyFileManagerDialog(String[] dirs, String[] dirShowNames) {
super(dirs, dirShowNames); }
public MyFileManagerDialog(Container parent, String[] dirs, String[] dirShowNames)
第 16 页 / 共 19 页
{
super(parent, dirs, dirShowNames); }
public MyFileManagerDialog(Container parent, String title, String[] dirs, String[] dirShowNames) {
super(parent, title, dirs, dirShowNames); }
public MyFileManagerDialog(Frame owner, String[] dirs, String[] dirShowNames) {
super(owner, dirs, dirShowNames); }
public MyFileManagerDialog(Frame owner, String title, String[] dirs, String[] dirShowNames) {
super(owner, title, dirs, dirShowNames); }
protected void onFileUpload() {
String id = super.getDir(); if (id == null) {
NCOptionPane.showMessageDialog(this, NCLangRes.getInstance ().getStrByID(\return; }
UIFileChooser fileChooser = new UIFileChooser(); fileChooser.setFileSelectionMode(0); fileChooser.setMultiSelectionEnabled(false); int rs = fileChooser.showOpenDialog(this); if (rs != 0) return;
File file = fileChooser.getSelectedFile(); if (!(file.exists())) return;
String localFilePath = file.getAbsolutePath();
String fileName = fileChooser.getSelectedFile().getName(); if ((localFilePath == null) || (localFilePath.length() <= 0)) return;
if (FileManagerUtil.isFileExistedServer(getDir(), fileName)) { int result = NCOptionPane.showConfirmDialog(this, NCLangRes.getInstance().
getStrByID(\().
第 17 页 / 共 19 页
getStrByID(\if (result != 0) { return; } }
//add by yzk at 2010-06-22 start
int iFileLength = (int) fileChooser.getSelectedFile().length(); if (iFileLength > iMaxAttachmentSize) {
MessageDialog.showHintDlg(this.getParent(), \提示信息\附件大小不 能超过 \!\return; }
int res = this.getUITreeFile().getRowCount(); if(res >= iMaxCount){
MessageDialog.showHintDlg(this.getParent(), \提示信息\附件个数不能超 过5个!\return; }
//add by yzk at 2010-06-22 end
FileManagerUtil.saveFileToServer(id, localFilePath); updateTree(); } }
1.8.4 存储特殊字符
数据库用BLOB类型,模板上设置成大文本和字符都可以 这个一般都是用来存图片什么的
1.9 常用的算法 1.9.1 判断字符串是否为数字
1用JAVA自带的函数
public static boolean isNumeric(String str){
第 18 页 / 共 19 页
for (int i = str.length();--i>=0;){ if (!Character.isDigit(str.charAt(i))){ return false; } } return true; }
2用正则表达式
public static boolean isNumeric(String str){ Pattern pattern = Pattern.compile(\ return pattern.matcher(str).matches(); }
3用ascii码
public static boolean isNumeric(String str){ for(int i=str.length();--i>=0;){ int chr=str.charAt(i); if(chr<48 || chr>57) return false; }
第 19 页 / 共 19 页