增加字典类型

DictionaryKindListPane.xhtml:

<h:commandLink value="增加字典类型" style="font-size: 10pt; color: blue; text-decoration: none" action="AddDictionaryKindPane"> </h:commandLink>

AddDictionaryKindPanel.xhtml:

保存是校验

<div align="center"> <h:commandButton tabindex="7" value=" 保 存 " id="Save" action="#{dictionaryKindModel.save}" /> </div>

DictionaryKindModel.java 里面的保存方法,保存时校验字典类型非中文

/** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:18:01 AM * @function:保存方法 * @return: */ public String save() { // 保存时校验,类型为非中文字符 if (!this.validate(dictionaryKind.getKind())) { return null; } else { transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult( TransactionStatus transactionStatus) { bolCanSave = true; // 遍历字典类型list,如果list中存在字典类型代码相同的字典类型则不能保存 List<DictionaryKind> tempList = dictionaryKindDAOEx .findAll(); for (int i = 0; tempList != null && i < tempList.size(); i++) { boolean bolUpdate = true; // 字典类型已存在且非逻辑删除 if (dictionaryKind.getKind().equals( tempList.get(i).getKind())) { bolCanSave = false; for (int j = 0; dklist != null && j < dklist.size(); j++) { if (dictionaryKind.getKind().equals( dklist.get(j).getKind())) { addMessage(FacesMessage.SEVERITY_WARN, null, "该字典类型已存在,请使用其他类型!"); bolUpdate = false; break; } } // 字典类型已逻辑删除,设置删除标志为0,并更新 if (bolUpdate) { tempList.get(i).setScbz(SCBZ0); dictionaryKind = tempList.get(i); dictionaryKindDAOEx.update(dictionaryKind); dklist.add(dictionaryKind); addMessage(FacesMessage.SEVERITY_INFO, null, "该字典类型已删除,现在恢复!"); } break; } } // 不存在相同的字典类型,则保存 if (bolCanSave) { dictionaryKind.setScbz(SCBZ0); dictionaryKindDAOEx.save(dictionaryKind); } } }); } return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:26:57 AM * @function:校验字典类型 * @param str是字典类型kind * @return: */ public boolean validate(String str) { if (str.matches("^[//u4e00-//u9fa5]+$")) { addErrorMessage("kind", "该字典类型只能是非中文的字符!"); return false; } return true; }

 

 

 

 

你可能感兴趣的:(增加字典类型)