DictionaryKindModel
package cn.hnisi.gdrk.models.sys.dictionarykind; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import org.apache.commons.lang.StringUtils; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import cn.hnisi.architecture.AbstractModel; import cn.hnisi.architecture.common.util.CommonUtil; import cn.hnisi.dict.dictionarykind.DictionaryKind; import cn.hnisi.dict.dictionarykind.DictionaryKindDAOEx; import cn.hnisi.gdrk.utils.BizGlobalConstants; import cn.hnisi.gdrk.utils.GenarateConnection; import cn.hnisi.gdrk.utils.GlobalConstants; import cn.hnisi.gdrk.workflow.jbpmengine.util.QueryConVo; /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:10:59 AM * @function:字典类型 */ @SuppressWarnings("unchecked") public class DictionaryKindModel extends AbstractModel { public DictionaryKind dictionaryKind; public DictionaryKind cloneDicKind; public DictionaryKindDAOEx dictionaryKindDAOEx; // 控件可操作标志 // 控件可操作标志 private boolean bolSave = true; private boolean bolInput = true; private boolean bolModify = false; private boolean bolCancel = true; // 是否可保存标志 private boolean bolCanSave = true; // 查询条件变量 private String kindCondition; private String detailCondition; // 错误信息 private String errorStr; // 字典类型变量 private String dictionaryKindKind; private String dictionaryKindDetail; private String dictionaryKindSource; // 常量 private static final String SCBZ0 = "0"; private static final String SCBZ1 = "1"; private static final String ModifyDictionaryKindPane = "ModifyDictionaryKindPane"; private static final String DictionaryKindListPane = "DictionaryKindListPane"; private static final String AddDictionaryKindPane = "AddDictionaryKindPane"; // 分页变量 protected int rowCount = 0; // 记录数 protected int pageCount = 0; // 总页数 protected int pageSize = GlobalConstants.DEFAULT_PAGE_SIZE;// 每页显示的条数 protected int currentPageNumber = GlobalConstants.DEFAULT_PAGE_NUMBER;// 当前页码 protected int gotoPageNumber = GlobalConstants.DEFAULT_PAGE_NUMBER; public List<DictionaryKind> dklist; /** * * @author:denghuimin,yanghanming * @createTime:Jul 9, 2009 12:18:01 AM * @function:重写父类方法doSaveToDB */ public String doSaveToDB() { this.save(); this.fromOutcome = AddDictionaryKindPane; return errorStr; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:18:01 AM * @function:保存方法 * @return: */ public String save() { bolCanSave = true; // 遍历字典类型list,如果list中存在字典类型代码相同的字典类型则不能保存 List<DictionaryKind> tempList = dictionaryKindDAOEx.findAll(); for (int i = 0; tempList != null && i < tempList.size(); i++) { // 字典类型已存在 if (StringUtils.equals(this.getDictionaryKindKind(), tempList .get(i).getKind())) { bolCanSave = false; // 非逻辑删除 if (StringUtils.equals(tempList.get(i).getScbz(), SCBZ0)) { addMessage(FacesMessage.SEVERITY_WARN, null, "该字典类型已存在,请使用其他类型!"); break; } // 逻辑删除则恢复 else { tempList.get(i).setScbz(SCBZ0); dictionaryKind = tempList.get(i); dictionaryKindDAOEx.attachDirty(dictionaryKind); dklist.add(dictionaryKind); addMessage(FacesMessage.SEVERITY_INFO, null, "该字典类型已删除,现在恢复!"); break; } } } // 不存在相同的字典类型,则保存 if (bolCanSave) { dictionaryKind.setScbz(SCBZ0); dictionaryKind.setKind(this.getDictionaryKindKind()); dictionaryKind.setDetail(this.getDictionaryKindDetail()); dictionaryKind.setSource(this.getDictionaryKindSource()); dictionaryKindDAOEx.save(dictionaryKind); } return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:28:00 AM * @function:更新字典类型 * @return: */ public String update() { transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult( TransactionStatus transactionStatus) { bolSave = true; bolInput = true; bolModify = false; bolCancel = true; dictionaryKindDAOEx.attachDirty(dictionaryKind); } }); return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:30:00 AM * @function:取消修改操作 * @return: */ public String recover() { DictionaryKind cloneTemp = (DictionaryKind) CommonUtil .cloneObject(cloneDicKind); this.setDictionaryKind(cloneTemp); return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:33:12 AM * @function:逻辑删除字典类型 * @return: */ public String remove() { transactionTemplate.execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult( TransactionStatus transactionStatus) { // 获取页面传来的字典类型的id,遍历list表,如果list存在相同的字典,则从list中删除 Map requestParams = FacesContext.getCurrentInstance() .getExternalContext().getRequestParameterMap(); String id = (String) requestParams.get("id"); for (int i = 0; dklist != null && i < dklist.size(); i++) { dictionaryKind = dklist.get(i); if (StringUtils.equals(dictionaryKind.getId(), id)) { dklist.remove(i); break; } } // 逻辑删除字典,设置删除标志,1代表删除,0代表不删除 dictionaryKind.setScbz(SCBZ1); dictionaryKindDAOEx.attachDirty(dictionaryKind); } }); return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:35:00 AM * @function:点击修改时候,改变控件的可用性 * @return: */ public String changeFlag() { bolSave = false; bolInput = false; bolModify = true; bolCancel = false; return null; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:37:36 AM * @function:跳转到修改字典类型页面 * @return: */ public String to() { bolSave = true; bolInput = true; bolModify = false; bolCancel = true; // 获取页面传来的字典id Map requestParams = FacesContext.getCurrentInstance() .getExternalContext().getRequestParameterMap(); String id = (String) requestParams.get("id"); // 遍历list表,在list表中找到相应的字典,并克隆相应的副本作为取消修改操作时恢复字典 for (int i = 0; dklist != null && i < dklist.size(); i++) { dictionaryKind = (DictionaryKind) dklist.get(i); if (StringUtils.equals(dictionaryKind.getId(), id)) { this.setDictionaryKind(dictionaryKind); cloneDicKind = (DictionaryKind) CommonUtil .cloneObject(dictionaryKind); break; } } return ModifyDictionaryKindPane; } /** * * @author:denghuimin,yanghanming * @createTime:Jul 7, 2009 11:41:24 AM * @function:重写父类的findByQueryCondition方法 * @param otherCondition * 查询条件 * @return: */ public String findByQueryCondition(String otherCondition) { String errMessage = ""; List list = new ArrayList<QueryConVo>(); if (StringUtils.isNotBlank(this.getKindCondition())) { QueryConVo conVo = new QueryConVo(dictionaryKindDAOEx.KIND, this .getKindCondition()); list.add(conVo); } if (StringUtils.isNotBlank(this.getDetailCondition())) { QueryConVo conVo = new QueryConVo(dictionaryKindDAOEx.DETAIL, this .getDetailCondition()); list.add(conVo); } dklist = new ArrayList<DictionaryKind>(); GenarateConnection gc = (GenarateConnection) getCtx().getBean( BizGlobalConstants.X_GCONNECTION); String hql = "from DictionaryKind as ti where 1=1 and ti.scbz ='0'"; try { this.dklist = gc.findListForPage(hql, list, this .getCurrentPageNumber(), this.getPageSize()); this.rowCount = gc.findCountForPage(hql, list, this .getCurrentPageNumber(), this.getPageSize()); } catch (Exception e) { e.printStackTrace(); } return errMessage; } public String doBriefQuery() { String errMessage = ""; errMessage = findByQueryCondition(dictionaryKind.getKind()); this.fromOutcome = DictionaryKindListPane; return errMessage; } /** * 获取记录总数 * * @return */ public int getRowCount() { return rowCount; } /** * 设置记录总数 * * @param recordCount */ public void setRowCount(int recordCount) { this.rowCount = recordCount; } /** * 获取页数 */ public int getPageCount() { if ((rowCount % pageSize) == 0) { pageCount = this.rowCount / this.pageSize; } else { pageCount = this.rowCount / this.pageSize + 1; } return pageCount; } /** * 设置页数 */ public void setPageCount(int pageCount) { this.pageCount = pageCount; } /** * 获取每页记录数 */ public int getPageSize() { return pageSize; } /** * 设置每页记录数 * * @param pageSize */ public void setPageSize(int pageSize) { if (pageSize < 1) { this.pageSize = GlobalConstants.DEFAULT_PAGE_SIZE; } else { this.pageSize = pageSize; } } /** * 获取指定页 * * @return */ public int getCurrentPageNumber() { return currentPageNumber; } /** * 设置指定页 * * @param arg */ public void setCurrentPageNumber(int arg) { if (arg < 1) { this.currentPageNumber = GlobalConstants.DEFAULT_PAGE_NUMBER; } else { this.currentPageNumber = arg; } } /** * 第一页 */ public String first() { this.currentPageNumber = 1; doBriefQuery(); toMerge(); return null; } /** * 最后一页 * * @return */ public String last() { this.currentPageNumber = this.pageCount; doBriefQuery(); toMerge(); return null; } /** * 上页 */ public String previous() { this.currentPageNumber--; if (this.currentPageNumber < 1) this.currentPageNumber = 1; if (this.currentPageNumber > this.pageCount) this.currentPageNumber = this.pageCount; doBriefQuery(); toMerge(); return null; } /** * 下页 * * @return */ public String next() { this.currentPageNumber++; if (this.currentPageNumber < 1) this.currentPageNumber = 1; if (this.currentPageNumber > this.pageCount) this.currentPageNumber = this.pageCount; doBriefQuery(); toMerge(); return null; } /** * 去到指定页 * * @return */ public String go() { if (this.gotoPageNumber < 1) { this.currentPageNumber = 1; gotoPageNumber = 1; } else if (this.gotoPageNumber > this.pageCount) { this.currentPageNumber = this.pageCount; this.gotoPageNumber = this.pageCount; } else { this.currentPageNumber = this.gotoPageNumber; } doBriefQuery(); toMerge(); return null; } /* * 获取指定页 */ public int getGotoPageNumber() { return gotoPageNumber; } public void setGotoPageNumber(int gotoPageNumber) { this.gotoPageNumber = gotoPageNumber; } public DictionaryKind getDictionaryKind() { return dictionaryKind; } public void setDictionaryKind(DictionaryKind dictionaryKind) { this.dictionaryKind = dictionaryKind; } public DictionaryKindDAOEx getDictionaryKindDAOEx() { return dictionaryKindDAOEx; } public void setDictionaryKindDAOEx(DictionaryKindDAOEx dictionaryKindDAOEx) { this.dictionaryKindDAOEx = dictionaryKindDAOEx; } public boolean isBolSave() { return bolSave; } public void setBolSave(boolean bolSave) { this.bolSave = bolSave; } public boolean isBolInput() { return bolInput; } public void setBolInput(boolean bolInput) { this.bolInput = bolInput; } public boolean isBolModify() { return bolModify; } public void setBolModify(boolean bolModify) { this.bolModify = bolModify; } public boolean isBolCancel() { return bolCancel; } public void setBolCancel(boolean bolCancel) { this.bolCancel = bolCancel; } public boolean isBolCanSave() { return bolCanSave; } public void setBolCanSave(boolean bolCanSave) { this.bolCanSave = bolCanSave; } public List<DictionaryKind> getDklist() { return dklist; } public void setDklist(List<DictionaryKind> dklist) { this.dklist = dklist; } public DictionaryKind getCloneDicKind() { return cloneDicKind; } public void setCloneDicKind(DictionaryKind cloneDicKind) { this.cloneDicKind = cloneDicKind; } public String getKindCondition() { return kindCondition; } public void setKindCondition(String kindCondition) { this.kindCondition = kindCondition; } public String getDetailCondition() { return detailCondition; } public void setDetailCondition(String detailCondition) { this.detailCondition = detailCondition; } public static String getSCBZ0() { return SCBZ0; } public static String getSCBZ1() { return SCBZ1; } public static String getModifyDictionaryKindPane() { return ModifyDictionaryKindPane; } public static String getDictionaryKindListPane() { return DictionaryKindListPane; } public String getDictionaryKindKind() { return dictionaryKindKind; } public void setDictionaryKindKind(String dictionaryKindKind) { this.dictionaryKindKind = dictionaryKindKind; } public String getDictionaryKindDetail() { return dictionaryKindDetail; } public void setDictionaryKindDetail(String dictionaryKindDetail) { this.dictionaryKindDetail = dictionaryKindDetail; } public String getDictionaryKindSource() { return dictionaryKindSource; } public void setDictionaryKindSource(String dictionaryKindSource) { this.dictionaryKindSource = dictionaryKindSource; } }
DictionaryKindListPane
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:jsfext="http://www.hnisi.cn/jsfext" xmlns:a4j="http://richfaces.org/a4j" xmlns:c="http://java.sun.com/jstl/core"> <ui:composition template="/cn/hnisi/gdrk/GDRKWorkspace.xhtml"> <ui:define name="BizTitleAndToolBar"> <jsfext:defaultFocusedElement value="kind" /> <h:form style="margin:0px;" mce_style="margin:0px;"> <jsfext:pageTitle title="字典类型列表"> <h:commandLink value="增加字典类型(n)" styleClass="toolbarButton" accesskey="n" onmouseout="toolbarButtonMouseOut(this)" onmouseover="toolbarButtonMouseOver(this)" action="AddDictionaryKindPane"> </h:commandLink> <rich:spacer width="10" /> <h:outputLabel value=" "></h:outputLabel> <jsfext:instantHelp helpId="dzgl_bgmlp" /> </jsfext:pageTitle> </h:form> </ui:define> <ui:define name="QueryConditionPanel"> <h:form style="margin:0px;" mce_style="margin:0px;" id="theBriefQueryForm"> <table align="center" width="80%"> <tr width="60%"> <td align="right" style="font-size: 10pt;" mce_style="font-size: 10pt;" width="40%"> 字典类型: <jsfext:inputText value="#{dictionaryKindModel.kindCondition}" id="kind" tabindex="1" maxlength="64"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> <td align="right" style="font-size: 10pt;" mce_style="font-size: 10pt;" width="40%"> 字典中文含义: <jsfext:inputText value="#{dictionaryKindModel.detailCondition}" id="zdzwhy" tabindex="2" maxlength="65"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> <td align="center" style="font-size: 10pt;" mce_style="font-size: 10pt;" width="20%"> <h:commandButton value=" 查 询 " action="#{dictionaryKindModel.doBriefQuery}" tabindex="3"></h:commandButton> </td> </tr> </table> </h:form> </ui:define> <ui:define name="QueryResult"> <h:form style="margin:0px" mce_style="margin:0px"> <t:saveState value="#{dictionaryKindModel}" /> <table> <tr> <td> <jsfext:dataTableEx needRowClickAction="false" id="dsList2" model="#{dictionaryKindModel}" columns="3" checkbox="false" width="100%" value="#{dictionaryKindModel.dklist}" isJbpmList="false" height="250" fsWidth="900" fsHeight="520"> <rich:column colspan="1"> <f:facet name="header"> <h:outputLabel value="类型" /> </f:facet> <div align="center"> <h:commandLink style="font-size: 10pt; color: blue; text-decoration: none" value="#{temp.kind}" action="#{dictionaryKindModel.to}"> <f:param name="id" value="#{temp.id}"></f:param> </h:commandLink> </div> </rich:column> <jsfext:columnEx title="中文含义" value="#{temp.detail}" isJbpmList="false" model="#{dictionaryKindModel}" haveAction="true"> </jsfext:columnEx> <jsfext:columnEx title="来源" value="#{temp.source}" isJbpmList="false" model="#{dictionaryKindModel}" haveAction="true"> </jsfext:columnEx> <rich:column colspan="1"> <f:facet name="header"> <h:outputLabel value="删除" /> </f:facet> <div align="center"> <t:commandLink styleClass="cbLink_table" value="删除" action="#{dictionaryKindModel.remove}" onclick="if(!confirm('确定要删除吗?')) return false;"> <f:param name="id" value="#{temp.id}"></f:param> </t:commandLink> </div> </rich:column> <rich:column colspan="1"> <f:facet name="header"> <h:outputLabel value="维护字典" /> </f:facet> <div align="center"> <t:commandLink value="维护字典" styleClass="cbLink_table" action="#{dictionaryModel.onBriefQueryFormSubmit}"> <f:param name="kind" value="#{temp.kind}"></f:param> <f:param name="detail" value="#{temp.detail}"></f:param> </t:commandLink> </div> </rich:column> </jsfext:dataTableEx> </td> </tr> </table> </h:form> </ui:define> </ui:composition> </html>
ModifyDictionaryKindPane
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:jsfext="http://www.hnisi.cn/jsfext" xmlns:a4j="http://richfaces.org/a4j" xmlns:c="http://java.sun.com/jstl/core"> <ui:composition template="/cn/hnisi/gdrk/GDRKWorkspace.xhtml"> <ui:define name="BizTitleAndToolBar"> <h:form style="margin:0px;" mce_style="margin:0px;"> <jsfext:pageTitle title="修改字典类型"> <h:commandLink value="返回(f)" styleClass="toolbarButton" accesskey="f" onmouseout="toolbarButtonMouseOut(this)" onmouseover="toolbarButtonMouseOver(this)" action="DictionaryKindListPane"> </h:commandLink> <rich:spacer width="10" /> <h:outputLabel value=" "></h:outputLabel> <jsfext:instantHelp helpId="dzgl_bgmlp" /> </jsfext:pageTitle> </h:form> </ui:define> <ui:define name="OperationPanel"> <ui:include src="/cn/hnisi/gdrk/sys/zdgl/zdlx/panel/ModifyDictionaryKindPanel.xhtml"></ui:include> </ui:define> </ui:composition> </html>
ModifyDictionaryKindPanel
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:jsfext="http://www.hnisi.cn/jsfext"> <ui:component> <jsfext:defaultFocusedElement value="zdzwhy" /> <h:form> <t:saveState value="#{dictionaryKindModel}" /> <fieldset align="center" style="width: 400; height: 300; border: 1px solid blue; margin: 0px; padding: 0px;"> <legend> <span style="font-size: 10pt; font-weight: bold; color: black" mce_style="font-size: 10pt; font-weight: bold; color: black">字典类型信息</span> </legend> <table width="100%" align="center" border="0"> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 类型: </td> <td> <jsfext:outputText value="#{dictionaryKindModel.dictionaryKind.kind}" id="lx" style="width:200px" maxlength="64" /> </td> </tr> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 中文含义: </td> <td> <jsfext:inputText id="zdzwhy" size="35" tabindex="1" value="#{dictionaryKindModel.dictionaryKind.detail}" required="true" cnName="字典中文含义" disabled="#{dictionaryKindModel.bolInput}" maxlength="65"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> </tr> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 来源: </td> <td> <jsfext:selectOneMenuEx2 id="ly" kind="LY" tabindex="2" style="width:166px" value="#{dictionaryKindModel.dictionaryKind.source}" disabled="#{dictionaryKindModel.bolInput}" maxlength="16"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:selectOneMenuEx2> </td> </tr> </table> <div align="center"> <h:commandButton tabindex="3" value=" 修 改 " id="modify" disabled="#{dictionaryKindModel.bolModify}" action="#{dictionaryKindModel.changeFlag}" immediate="true"> <f:param value="#{dictionaryKindModel.dictionaryKind.id}" name="id"></f:param> </h:commandButton> <h:commandButton tabindex="4" value=" 保 存 " id="save" action="#{dictionaryKindModel.update}" disabled="#{dictionaryKindModel.bolSave}" /> <h:commandButton tabindex="5" value=" 取 消 " id="cancel" action="#{dictionaryKindModel.recover}" disabled="#{dictionaryKindModel.bolCancel}"> </h:commandButton> </div> </fieldset> </h:form> </ui:component> </html>
AddDictionaryKindPane
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:jsfext="http://www.hnisi.cn/jsfext" xmlns:a4j="http://richfaces.org/a4j" xmlns:c="http://java.sun.com/jstl/core"> <ui:composition template="/cn/hnisi/gdrk/GDRKWorkspace.xhtml"> <ui:define name="BizTitleAndToolBar"> <h:form style="margin:0px;" mce_style="margin:0px;"> <jsfext:pageTitle title="增加字典类型"> <h:commandLink value=" 返回(f) " action="DictionaryKindListPane" styleClass="toolbarButton" accesskey="f" onmouseout="toolbarButtonMouseOut(this)" onmouseover="toolbarButtonMouseOver(this)"></h:commandLink> <rich:spacer width="10" /> <h:outputLabel value=" "></h:outputLabel> <jsfext:instantHelp helpId="dzgl_bgmlp" /> </jsfext:pageTitle> </h:form> </ui:define> <ui:define name="OperationPanel"> <ui:include src="/cn/hnisi/gdrk/sys/zdgl/zdlx/panel/AddDictionaryKindPanel.xhtml"></ui:include> </ui:define> </ui:composition> </html>
AddDictionaryKindPanel
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:jsfext="http://www.hnisi.cn/jsfext"> <ui:component> <jsfext:javascript path="/cn/hnisi/gdrk/sys/zdgl/zdlx/js/Validation.js" /> <jsfext:defaultFocusedElement value="lx" /> <h:form> <t:saveState value="#{dictionaryKindModel}" /> <fieldset align="center" style="width: 400; height: 150; border: 1px solid blue; margin: 0px; padding: 0px;"> <legend> <span style="font-size: 10pt; font-weight: bold; color: black" mce_style="font-size: 10pt; font-weight: bold; color: black">字典类型信息</span> </legend> <table width="100%" align="center" border="0"> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 类型: </td> <td> <jsfext:inputText id="lx" size="35" tabindex="4" value="#{dictionaryKindModel.dictionaryKindKind}" required="true" cnName="字典类型" maxlength="64"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> </tr> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 中文含义: </td> <td> <jsfext:inputText id="zdzwhy" size="35" tabindex="5" value="#{dictionaryKindModel.dictionaryKindDetail}" required="true" cnName="字典中文含义" maxlength="65"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" /> </jsfext:inputText> </td> </tr> <tr> <td align="right" style="font-size: 10pt" mce_style="font-size: 10pt"> 来源: </td> <td> <jsfext:selectOneMenuEx2 id="ly" kind="LY" tabindex="6" style="width:166px" value="#{dictionaryKindModel.dictionaryKindSource}"> <jsfext:jseventlistener event="onkeydown" listener="convertEnter2Tab()" maxlength="16" /> </jsfext:selectOneMenuEx2> </td> </tr> </table> <div align="center"> <h:commandButton tabindex="7" value=" 保 存 " id="Save" action="#{dictionaryKindModel.onMainFormSubmit}" onclick="return check()" /> </div> </fieldset> </h:form> </ui:component> </html>
Validation.js
function check() { var checkKind = document.getElementById("lx").value; var re=/^[a-zA-Z_/d]+$/gi; if (!re.test(checkKind)) { alert("类型只能为数字,英文字母和下划线!"); return false; } return true; }