`

Spring学习

 
阅读更多
#############sql-map-config.xml###############
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

<sqlMapConfig>
    <settings cacheModelsEnabled="true" enhancementEnabled="true" maxSessions="3000" maxTransactions="3000" maxRequests="3000" />
<sqlMap resource="com/tpaic/ruleengine/biz/persistence/dao/ibatis/sql/decisionRule.xml"/>
</sqlMapConfig>
###############decisionRule.xml###########
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="decisionRule">

<insert id="decisionRule.insert" parameterClass="com.tpaic.ruleengine.domain.DecisionRule">
    <![CDATA[
INSERT INTO T_DECISION_RULE
  ( CREATED_BY,
    CREATED_DATE,
    UPDATED_BY,
    UPDATED_DATE,
    RULE_ID,
    RULE_DEFINE_ID,
    VERSION_NO
)
VALUES
  (#createdBy:VARCHAR#,
   sysdate,
   #updatedBy:VARCHAR#,
   sysdate,
   SEQ_DECISION_RULE.NEXTVAL,
   #ruleDefineId:VARCHAR#,
   #versionNo:VARCHAR#
  )
   ]]>
</insert>

<select id="decisionRule.search" parameterClass="com.tpaic.ruleengine.domain.DecisionRule"
resultClass="com.tpaic.ruleengine.domain.DecisionRule">
select
RULE_ID ruleId,
  RULE_DEFINE_ID ruleDefineId,
VERSION_NO versionNo
from T_DECISION_RULE c where DELETED_FLAG = '0'
<isNotEmpty prepend="and" property="ruleId">
c.RULE_ID = #ruleId#
</isNotEmpty>
<isNotEmpty prepend="and" property="ruleDefineId">
c.RULE_DEFINE_ID = #ruleDefineId#
</isNotEmpty>
<isNotEmpty prepend="and" property="versionNo">
c.VERSION_NO = #versionNo#
</isNotEmpty>
</select>

<select id="decisionRule.searchById" parameterClass="java.lang.String"
resultClass="com.tpaic.ruleengine.domain.DecisionRule">
select
RULE_ID ruleId,
  RULE_DEFINE_ID ruleDefineId,
VERSION_NO versionNo
from T_DECISION_RULE c where RULE_ID = #value#
</select>

<update id="decisionRule.update" parameterClass="com.tpaic.ruleengine.domain.DecisionRule">
update T_DECISION_RULE t set
t.updated_date=sysdate,
t.updated_by=#updatedBy#,
t.VERSION_NO = #versionNo#
where RULE_ID = #ruleId#
</update>

<delete id="decisionRule.delete" parameterClass="com.tpaic.ruleengine.domain.DecisionRule">
UPDATE T_DECISION_RULE
     SET DELETED_FLAG = '1',
         DELETED_DATE = sysdate,
         DELETED_BY =#deletedBy#
         WHERE RULE_ID = #ruleId#
</delete>
</sqlMap>
########################IDecisionRuleDao.java#######################
package com.tpaic.ruleengine.biz.persistence.dao.iface;

import java.util.List;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.tpfa.app.persistence.dao.DaoException;

public interface IDecisionRuleDao {

public void insert(DecisionRule decision) throws DaoException;

public List getDecisionRuleList(DecisionRule decision) throws DaoException;

public void delete(DecisionRule decision) throws DaoException;

public DecisionRule getDecisionRuleById(String id) throws DaoException;

public void update(DecisionRule decision) throws DaoException;
}
######################DecisionRuleColumnSqlMapDao################
package com.tpaic.ruleengine.biz.persistence.dao.ibatis;

import java.util.List;

import com.tpaic.ruleengine.biz.persistence.dao.iface.IDecisionRuleColumnDao;
import com.tpaic.ruleengine.domain.DecisionRuleColumn;
import com.tpaic.tpfa.app.persistence.dao.DaoException;
import com.tpaic.tpfa.app.persistence.dao.ibatis.BaseDAO;

public class DecisionRuleColumnSqlMapDao extends BaseDAO implements IDecisionRuleColumnDao {

public void insert(DecisionRuleColumn decision) throws DaoException {
this.insert("decisionRuleColumn.insert", decision);

}

public List getDecisionRuleColumnList(
DecisionRuleColumn decision) throws DaoException {
return this.queryForList("decisionRuleColumn.search", decision);
}

public void delete(DecisionRuleColumn decision) throws DaoException {
this.delete("decisionRuleColumn.delete", decision);

}

public DecisionRuleColumn getDecisionRuleColumnById(String id)
throws DaoException {
return (DecisionRuleColumn) this.queryForObject("decisionRuleColumn.searchById", id);
}

public DecisionRuleColumn getDecisionRuleColumnByRuleDefineId(
String ruleDefineId) throws DaoException {
return (DecisionRuleColumn) this.queryForObject("decisionRuleColumn.searchByRuleDefineId", ruleDefineId);
}


}
##########################IDecisionRuleBoService.java#################
package com.tpaic.ruleengine.biz.bo;

import java.util.List;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.tpfa.app.biz.service.BusinessServiceException;

public interface IDecisionRuleBoService {

public void insert(DecisionRule decision) throws BusinessServiceException;

public List getDecisionRuleList(DecisionRule decision) throws BusinessServiceException;

public void delete(DecisionRule decision) throws BusinessServiceException;

public DecisionRule getDecisionRuleById(String id) throws BusinessServiceException;

public void update(DecisionRule decision) throws BusinessServiceException;
}
######################DecisionRuleBoServiceImp.java##########
package com.tpaic.ruleengine.biz.bo.impl;
import java.util.List;

import com.tpaic.ruleengine.biz.bo.IDecisionRuleBoService;
import com.tpaic.ruleengine.biz.persistence.dao.iface.IDecisionRuleDao;
import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.tpfa.app.biz.service.BusinessServiceException;
import com.tpaic.tpfa.app.persistence.dao.DaoException;

public class DecisionRuleBoServiceImp implements IDecisionRuleBoService {

private IDecisionRuleDao decisionRuleDao;

public void setDecisionRuleDao(IDecisionRuleDao decisionRuleDao) {
this.decisionRuleDao = decisionRuleDao;
}

public void insert(DecisionRule decision)
throws BusinessServiceException {
try {
decisionRuleDao.insert(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public List getDecisionRuleList(DecisionRule decision) throws BusinessServiceException {
try {
return decisionRuleDao.getDecisionRuleList(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}
public void delete(DecisionRule decision)
throws BusinessServiceException {
try {
decisionRuleDao.delete(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public DecisionRule getDecisionRuleById(String id)
throws BusinessServiceException {
try {
return decisionRuleDao.getDecisionRuleById(id);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public void update(DecisionRule decision) throws BusinessServiceException {
try {
decisionRuleDao.update(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

}
#####################IDecisionRuleService.java##############
package com.tpaic.ruleengine.biz.service;

import java.util.List;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.tpfa.app.biz.service.BusinessServiceException;

public interface IDecisionRuleService {

public void insert(DecisionRule decision) throws BusinessServiceException;

public List getDecisionRuleList(DecisionRule decision) throws BusinessServiceException;

public DecisionRule getDecisionRuleById(String id) throws BusinessServiceException;

public void delete(DecisionRule[] decisions) throws BusinessServiceException;

public void update(DecisionRule decision) throws BusinessServiceException;


}
#########################DecisionRuleServiceImp.java###############
package com.tpaic.ruleengine.biz.service.impl;


import java.util.List;

import com.tpaic.ruleengine.biz.bo.IDecisionColumnDefineBoService;
import com.tpaic.ruleengine.biz.bo.IDecisionRuleBoService;
import com.tpaic.ruleengine.biz.bo.IDecisionRuleColumnBoService;
import com.tpaic.ruleengine.biz.bo.IDecisionRuleDefineBoService;
import com.tpaic.ruleengine.biz.bo.IDecisionTableBoService;
import com.tpaic.ruleengine.biz.service.IDecisionRuleService;
import com.tpaic.ruleengine.domain.DecisionColumnDefine;
import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.ruleengine.domain.DecisionRuleColumn;
import com.tpaic.ruleengine.domain.DecisionRuleDefine;
import com.tpaic.ruleengine.domain.DecisionTable;
import com.tpaic.tpfa.app.biz.service.BusinessServiceException;
import com.tpaic.tpfa.app.persistence.dao.DaoException;

public class DecisionRuleServiceImp implements IDecisionRuleService {

private IDecisionRuleBoService decisionRuleBo;
private IDecisionTableBoService  decisionTableBo;
private IDecisionRuleDefineBoService  decisionRuleDefineBo;
private IDecisionRuleColumnBoService  decisionRuleColumnBo;
private IDecisionColumnDefineBoService  decisionColumnDefineBo;

public void setDecisionRuleBo(IDecisionRuleBoService decisionRuleBo) {
this.decisionRuleBo = decisionRuleBo;
}

public void setDecisionColumnDefineBo(
IDecisionColumnDefineBoService decisionColumnDefineBo) {
this.decisionColumnDefineBo = decisionColumnDefineBo;
}

public void setDecisionRuleColumnBo(
IDecisionRuleColumnBoService decisionRuleColumnBo) {
this.decisionRuleColumnBo = decisionRuleColumnBo;
}

public void setDecisionRuleDefineBo(
IDecisionRuleDefineBoService decisionRuleDefineBo) {
this.decisionRuleDefineBo = decisionRuleDefineBo;
}

public IDecisionTableBoService getDecisionTableBo() {
return decisionTableBo;
}

public void setDecisionTableBo(IDecisionTableBoService decisionTableBo) {
this.decisionTableBo = decisionTableBo;
}

public DecisionRule getDRuleAndRelationById(String ruleId) {
try {
DecisionRule dRule = decisionRuleBo.getDecisionRuleById(ruleId);
//决策表对象
DecisionTable dTable = decisionTableBo.getDecisionTableByRuleId(ruleId);
dRule.setTable(dTable);
//规则定义对象
DecisionRuleDefine dRuleDefine = decisionRuleDefineBo
.getDecisionRuleDefineById(dRule.getRuleDefineId());
dRule.setRuleDefine(dRuleDefine);
//关联表对象
// DecisionRuleColumn dRuleColumn = decisionRuleColumnBo
// .getDecisionRuleColumnByRuleDefineId(dRule.getRuleDefineId());
//列对象列表
List dColumnDefineList = decisionColumnDefineBo
.getDColumnDefineListByRuleDefineId(dRule.getRuleDefineId());
dRuleDefine.setColumnDefines(dColumnDefineList);
return dRule;
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public void insert(DecisionRule decision) throws BusinessServiceException{
try {
decisionRuleBo.insert(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public List getDecisionRuleList(DecisionRule decision) throws BusinessServiceException {
try {
return decisionRuleBo.getDecisionRuleList(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public void delete(DecisionRule[] decisions) throws BusinessServiceException {
try {
for(int i=0; i<decisions.length; i++) {
decisionRuleBo.delete(decisions[i]);
}
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public DecisionRule getDecisionRuleById(String id)
throws BusinessServiceException {
try {
return decisionRuleBo.getDecisionRuleById(id);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}

public void update(DecisionRule decision) throws BusinessServiceException {
try {
decisionRuleBo.update(decision);
} catch (DaoException daoe) {
throw new BusinessServiceException(daoe);
}
}
}
###########################dao-context.xml##############
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
     <bean id="decisionRuleDao" class="com.tpaic.ruleengine.biz.persistence.dao.ibatis.DecisionRuleSqlMapDao">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
</beans>
########################service-context.xml################
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<!-- service start -->
<bean id="decisionRuleService" class="com.tpaic.ruleengine.biz.service.impl.DecisionRuleServiceImp" lazy-init="true">
        <property name="decisionRuleBo" ref="decisionRuleBo" />
        <property name="decisionTableBo" ref="decisionTableBo" />
        <property name="decisionRuleDefineBo" ref="decisionRuleDefineBo" />
        <property name="decisionRuleColumnBo" ref="decisionRuleColumnBo" />
        <property name="decisionColumnDefineBo" ref="decisionColumnDefineBo" />
    </bean>
<!-- service end -->
<!-- bo start -->
<bean id="decisionRuleBo" class="com.tpaic.ruleengine.biz.bo.impl.DecisionRuleBoServiceImp">
        <property name="decisionRuleDao" ref="decisionRuleDao" />
    </bean>
<!-- bo end -->
<!-- transaction start -->
<bean id="decisionRuleServiceTransaction" parent="baseTransactionProxy">
        <property name="target" ref="decisionRuleService" />
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED,-BusinessServiceException</prop>
            </props>
        </property>
    </bean>
</beans>
###################decisionRule_add.jsp#############
<%@ page contentType="text/html;charset=GBK"%>
<%@include file="../common/tag_include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>
新增规则实例
</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/default.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/menu.css" type="text/css">
<script language="javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/tooltip.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/xmlcommon.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/checkfield.js"></script>
</head>
<body topmargin="0" leftmargin="0">
<form name="form1" method="post" action="decisionRuleAdd.do">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="etable">
<input type="hidden" name="ruleId" value="<c:out value="${decisionRule.ruleId}"/>" />
<tr align="center">
<td class="content" colspan="4">
<b>
新增规则实例
</b>
</td>
</tr>

<tr>
                <td align="right" width="15%">版本号</td>
                <td width="35%" colspan="3">
<input type="text" name='versionNo' value=''>
                </td>
                </tr>
                         
               <tr>
                <td align="center" colspan="4">
                <input name="btnSave" value=" 保 存 " type="button" class="tpbutton" onclick="javasript:addObject();">
                </td>
                </tr>
</table>
</form>
</body>
</html>

<script languge="javascript">

function addObject(){
var versionNo = form1.versionNo.value;
if(versionNo.trim()==""){
alert("版本号不能为空");
form1.versionNo.focus();
return;
}
    form1.submit();
    form1.btnSave.disabled=true;
}

function successCallback(){
searchForm();
}

</script>
#######################decisionRule_edit.jsp#############
<%@ page contentType="text/html;charset=GBK"%>
<%@include file="../common/tag_include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>
修改规则实例
</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/default.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/menu.css" type="text/css">
<script language="javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/tooltip.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/xmlcommon.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/checkfield.js"></script>
</head>
<body topmargin="0" leftmargin="0">
<form name="form1" method="post" action="decisionRuleUpdate.do">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="etable">
<input type="hidden" name="ruleId" value="<c:out value="${decisionRule.ruleId}"/>" />
<tr align="center">
<td class="content" colspan="4">
<b>
修改规则实例
</b>
</td>
</tr>

<tr>
                <td align="right" width="15%">版本号</td>
                <td width="35%" colspan="3">
                <input type="text" name='versionNo' value='<c:out value="${decisionRule.versionNo}"/>'>
                </td>
                </tr>
                         
              
               <tr>
                <td align="center" colspan="4">
                <input name="btnSave" value=" 保 存 " type="button" class="tpbutton" onclick="javasript:addObject();">
                </td>
                </tr>
</table>
</form>
</body>
</html>

<script languge="javascript">

function addObject(){
var versionNo = form1.versionNo.value;
if(versionNo.trim()==""){
alert("版本不能为空");
form1.versionNo.focus();
return;
}
    form1.submit();
    form1.btnSave.disabled=true;
}

function successCallback(){
searchForm();
}

</script>
#############################decisionRule_search.jsp###############
<%@ page contentType="text/html;charset=GBK"%>
<%@include file="../common/tag_include.jsp"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=GBK">
        <title>规则实例管理</title>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/js/default.css" type="text/css">
        <link rel="stylesheet" href="<%=request.getContextPath()%>/js/menu.css" type="text/css">
        <script language="javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
        <script language="javascript" src="<%=request.getContextPath()%>/js/tooltip.js"></script>
        <script language="javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
        <script language="javascript" src="<%=request.getContextPath()%>/js/xmlcommon.js"></script>
        <script language="javascript" src="<%=request.getContextPath()%>/js/checkfield.js"></script>
    </head>
    <body topmargin="0" leftmargin="0">
        <form name="form1" method="post" action="decisionRuleSearch.do">
            <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="etable">
                <TR align="center">
                    <TD class="content" colspan="4">
                        <b> 规则实例管理 </b>
                    </TD>
                </TR>
                <TR>
                    <TD align="right" width="15%">
                        规则ID
                    </TD>
                    <TD width="35%">
                        <input type="text" name="ruleId"  value="<c:out value="${decisionRuleSearch.ruleId}"/>"  />
                    </TD>
                    <TD align="right" width="15%">
                        规则定义
                    </TD>
                    <TD width="35%">
                        <input type="text" name="ruleDefineId"  value="<c:out value="${decisionRuleSearch.ruleDefineId}"/>"  />
                    </TD>
               </TR>
              <TR>
                    <TD align="right" width="15%">
                        版本号
                    </TD>
                    <TD width="35%" colspan="3">
                        <input type="text" name="versionNo"  value="<c:out value="${decisionRuleSearch.versionNo}"/>"  />
                    </TD>
               </TR>
                <TR align="center">
                    <TD colspan="4">
                        <input type="button" class="tpbutton"  value=" 查 询 " onClick="searchForm()">
                        &nbsp;
                        <input type="button" class="tpbutton"  value=" 新 增 " onClick="addObject();" />
                        &nbsp;
                    </TD>
                </TR>
            </table>

            <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="etable">
                <tr align="center">
                    <td class="content" colspan="15">
                        <b> 信息列表 </b>
                    </td>
                </tr>
                <TR>
                    <TD align="center">
                        <B> 选 择 </B>
                    </TD>
                    <TD align="center">
                        <B> 规则ID </B>
                    </TD>
                    <TD align="center">
                        <B> 规则定义</B>
                    </TD>
                    <TD align="center">
                        <B> 版本号 </B>
                    </TD>
                </TR>
                <c:forEach var="decisionRule" items="${decisionRuleList}" varStatus="status">
                    <TR>
                        <TD align="center">
                            <input type='checkbox' name='objectId' value="<c:out value="${decisionRule.ruleId}"/>" />
                        </TD>
                        <TD align="center">
                            <a href=javascript:viewDetail("<c:out value="${decisionRule.ruleId}" />");> <font color="blue"><c:out value="${decisionRule.ruleId}" /></font> </a>
                        </TD>
                      
<TD align="center">
                           <c:out value="${decisionRule.ruleDefineId}" />
                        </TD>
                        <TD align="center">
                        <c:out value="${decisionRule.versionNo}" />
                        </TD>
                    </TR>
                </c:forEach>
                <TR>
                    <TD colspan="15">
                        <input type="checkbox" name="cbSelectAll" id="cbSelectAll" class="checkall" onClick="selectAll_TP(form1,this);">
                        <label for="cbSelectAll">
                            全选/取消&nbsp;
                        </label>
                    </TD>
                </TR>
                <TR>
                    <TD align="center" colspan="15">
                    <input type="button" class="tpbutton"  name="btnEdit" value=" 修 改 " onClick="editObject();" />
                        &nbsp;
                        <input type="button" class="tpbutton"  name="btnDelete" value=" 删 除 " onClick="deleteObject();" />
                        &nbsp;
                    </TD>
                </TR>
                </form>
            </table>
            <jsp:include page="../common/pagdisp_model.jsp">
                <jsp:param name="pageId" value="QueryDecisionRuleList" />
                <jsp:param name="viewName" value="/ruleengine/decisionRule_search" />
                <jsp:param name="modelName" value="decisionRuleList" />
                <jsp:param name="formName" value="form1" />
            </jsp:include>
            <iFrame id="hiddenFrame" name="hiddenFrame" src="about:blank" width="100%" height=0 marginwidth=″0″ marginheight=″0″ frameborder="0" scrolling="no" space="0" vspace="0"></iframe>
    </body>
</html>

<script languge="javascript">

function searchForm(){
form1.target="_self";
form1.action="decisionRuleSearch.do";
form1.submit();
}

function selectAll_TP(formObj,obj){
var inputArray = formObj.elements;
for(var i = 0; i < inputArray.length; i++){
try{
if(inputArray[i].type == "checkbox"){
inputArray[i].checked = obj.checked;
}
}catch(e){
}
}
}

function viewDetail(objectId){
var url = "decisionRuleView.do?ruleId="+objectId;
window.open(url,'viewObject',"scrollbars=yes,status=no,width=800,height=600");
}

function addObject(){
var url = "decisionRuleAddInput.do";
    window.open(url,'createObject',"scrollbars=yes,status=no,width=800,height=600");
}

function addBatchObject(){
var url = "decisionRuleBatchAddInput.do";
    window.open(url,'createObject',"scrollbars=yes,status=no,width=800,height=600");
}

function editObject(){
var raAll = document.getElementsByName('objectId');
if (raAll.length<1){
alert("请先选中!");
return;
}
var objectId = "";
var k=-1;
for (var i=0; i<raAll.length; i++) {
if(raAll[i].checked == true ){
k++;
objectId = raAll[i].value;
}
}
if(k<0){
alert("请先选中!");
return;
}else if(k>0){
alert("只能选中一项!");
return;
}
    var url = "decisionRuleUpdateInput.do?ruleId="+objectId;
window.open(url,'editObject',"scrollbars=yes,status=no,width=800,height=600");
}

function deleteObject(){ 
    var raAll = document.getElementsByName('objectId');
if (raAll.length<1){
alert("请先选中!");
return;
}
var objectId = "";
var k=-1;
for (var i=0; i<raAll.length; i++) {
if(raAll[i].checked == true ){
k++;
objectId = raAll[i].value;
}
}
if(k<0){
alert("请先选中!");
return;
}
form1.target="hiddenFrame";
form1.action="decisionRuleDelete.do";
    form1.submit();
    form1.btnDelete.disabled=true;
}

function successCallback(){
searchForm();
}

</script>
#######################decisionRule_view.jsp#############
<%@ page contentType="text/html;charset=GBK"%>
<%@include file="../common/tag_include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>
查看规则实例
</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/default.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/menu.css" type="text/css">
<script language="javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/tooltip.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/xmlcommon.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/js/checkfield.js"></script>
</head>
<body topmargin="0" leftmargin="0">
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="etable">
<tr align="center">
<td class="content" colspan="4">
<b>
规则实例信息
</b>
</td>
</tr>
<tr>
                <td align="right" width="15%">规则ID</td>
                <td width="35%">
                <c:out value="${decisionRule.ruleId}"/>
                </td>
                <td align="right" width="15%">规则定义流水号</td>
                <td width="35%">
                    <c:out value="${decisionRule.ruleDefineId}"/>
                </td>
              </tr>
              <tr>
               <td align="right" width="15%">版本号</td>
               <td width="35%" colspan="3">
               <c:out value="${decisionRule.versionNo}"/>
               </td>
              </tr>
</table>
</form>
</body>
</html>

</script>
#########################tpaic-ruleengine-servlet.xml############
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:ruleengine-jdbc.properties</value>
                <value>classpath:ruleengine-jndi.properties</value>
            </list>
        </property>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
 

    <bean id="sessionInterceptor" class="com.tpaic.um.presentation.interceptor.SessionInterceptor">
        <property name="loginController" ref="loginController" />
    </bean>

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize">
            <value>5000000</value>
        </property>
        <property name="maxInMemorySize">
            <value>4096</value>
        </property>
        <property name="defaultEncoding">
            <value>GBK</value>
        </property>
    </bean>

    <bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean="sessionInterceptor" />
            </list>
        </property>
    </bean>
   
<bean name="dispatchService" class="com.tpaic.tpfa.app.biz.dispatch.impl.ServiceControllerLocalImpl">
        <property name="beanFactoryLocator" value="com/tpaic/ruleengine/biz/beanRefContext.xml" />
        <property name="beanFactoryLocatorKey" value="com.tpaic.ruleengine.biz" />
    </bean>

    <bean name="loginController" class="com.tpaic.ruleengine.presentation.controller.LoginController">
        <property name="dispatch" ref="dispatchService" />
    </bean>
    <bean name="/prelogin.do" class="com.tpaic.um.presentation.controller.PreloginController">
        <property name="dispatch" ref="dispatchService" />
    </bean>
    <bean name="/index.do" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="index" />
    </bean>
<bean name="/menu.do" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="menu" />
    </bean>
    <bean name="/login_info.do" class="com.tpaic.ruleengine.presentation.controller.LoginInfoController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="login_info" />
    </bean>
    <bean name="/head.do" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="head" />
    </bean>

    <bean name="/**/pagination.do" class="com.tpaic.tpfa.app.web.PaginationController"></bean>
    <bean name="aggregatedSearchSupport" class="com.tpaic.ruleengine.util.AggregatedSearchSupport">
        <property name="dispatch" ref="dispatchService" />
    </bean>
<!-- 规则定义 -->
     <bean name="/decisionRuleDefineAddInput.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineAddInputController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="ruleengine/decisionRuleDefine_add" />
    </bean>
    <bean name="/decisionRuleDefineAdd.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineAddController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="common/successCallback" />
    </bean>
    <bean name="/decisionRuleDefineSearch.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineSearchController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="ruleengine/decisionRuleDefine_search" />
    </bean>
   <bean name="/decisionRuleDefineUpdateInput.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineUpdateInputController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="ruleengine/decisionRuleDefine_edit" />
    </bean>
    <bean name="/decisionRuleDefineUpdate.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineUpdateController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="common/successCallback" />
    </bean>
    <bean name="/decisionRuleDefineDelete.do" class="com.tpaic.ruleengine.presentation.controller.DecisionRuleDefineDeleteController">
        <property name="dispatch" ref="dispatchService" />
        <property name="formView" value="common/successCallback" />
    </bean>
   
</beans>
########################DecisionRuleSearchController.java#############
package com.tpaic.ruleengine.presentation.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.ruleengine.util.ServiceRequestID;
import com.tpaic.ruleengine.util.Constants;
import com.tpaic.tpfa.app.dto.ActionDTO;
import com.tpaic.tpfa.app.util.StringUtil;
import com.tpaic.tpfa.app.web.AbstractViewController;
import com.tpaic.tpfa.app.web.PaginationController;
import com.tpaic.tpfa.app.web.util.DTOBuilder;

public class DecisionRuleSearchController extends AbstractViewController {

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        Map model = new HashMap();
        try {
            DecisionRule rule = this.getObjectForSearch(request);
            model.put("decisionRuleSearch", rule);
            ActionDTO actionDTO = new ActionDTO();
            actionDTO.setOperationType(Constants.ACTION_METHOD_SEARCH);
            actionDTO.setObject(rule);

            List decisionRuleList = (List) dispatch.dispatchRequest(actionDTO,
                    ServiceRequestID.DECISION_RULE_ACTION);
            model.put("decisionRuleList", decisionRuleList);
            model = PaginationController.page(request, "QueryDecisionRuleList", model,
                    "decisionRuleList");
            return new ModelAndView(this.getFormView(), model);
        } catch (Exception e) {
            e.printStackTrace();
            model = new HashMap();
            model.put(Constants.ERROR_MSG, e.getMessage());
            model.put(Constants.ERROR_EXCEPTION, StringUtil
                    .getThrowableString(e));
            return new ModelAndView(Constants.ERROR_PAGE, model);
        }
    }
    private DecisionRule getObjectForSearch(HttpServletRequest request) throws Exception {
    DecisionRule obj = new DecisionRule();
DTOBuilder.setDTOValue(request, obj);
return obj;
    }

}
########################DecisionRuleUpdateController.java############
package com.tpaic.ruleengine.presentation.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.ruleengine.util.ServiceRequestID;
import com.tpaic.ruleengine.util.Constants;
import com.tpaic.tpfa.app.dto.ActionDTO;
import com.tpaic.tpfa.app.util.StringUtil;
import com.tpaic.tpfa.app.web.AbstractViewController;
import com.tpaic.tpfa.app.web.util.DTOBuilder;

public class DecisionRuleUpdateController extends AbstractViewController {

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map model = new HashMap();
try {
DecisionRule obj = getObjectByInput(request);
obj.setUpdatedBy("admin");
ActionDTO actionDTO = new ActionDTO();
actionDTO.setOperationType(Constants.ACTION_METHOD_UPDATE);
actionDTO.setObject(obj);
dispatch.dispatchRequest(actionDTO, ServiceRequestID.DECISION_RULE_ACTION);

return new ModelAndView(this.getFormView(), model);
} catch (Exception e) {
e.printStackTrace();
model = new HashMap();
model.put(Constants.ERROR_MSG, e.getMessage());
model.put(Constants.ERROR_EXCEPTION, StringUtil.getThrowableString(e));
return new ModelAndView(Constants.ERROR_PAGE, model);
}
}

private DecisionRule getObjectByInput(HttpServletRequest request)throws Exception{
DecisionRule obj = new DecisionRule();
DTOBuilder.setDTOValue(request, obj);
return obj;
}

}

###########################DecisionRuleUpdateInputController.java############
package com.tpaic.ruleengine.presentation.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.ruleengine.util.ServiceRequestID;
import com.tpaic.ruleengine.util.Constants;
import com.tpaic.tpfa.app.dto.ActionDTO;
import com.tpaic.tpfa.app.util.StringUtil;
import com.tpaic.tpfa.app.web.AbstractViewController;
import com.tpaic.tpfa.app.web.exception.WebException;

public class DecisionRuleUpdateInputController extends AbstractViewController {

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map model = new HashMap();
try {
String objectId = request.getParameter("ruleId");
objectId = objectId==null||objectId.trim().equals("")?null:objectId.trim();
if(objectId==null){
throw new WebException("无效编号");
}
ActionDTO actionDTO = new ActionDTO();
actionDTO.setOperationType(Constants.ACTION_METHOD_VIEW);
actionDTO.setObject(objectId);
DecisionRule obj = (DecisionRule)dispatch.dispatchRequest(actionDTO, ServiceRequestID.DECISION_RULE_ACTION);

model.put("decisionRule",obj);

return new ModelAndView(this.getFormView(), model);
} catch (Exception e) {
e.printStackTrace();
model = new HashMap();
model.put(Constants.ERROR_MSG, e.getMessage());
model.put(Constants.ERROR_EXCEPTION, StringUtil.getThrowableString(e));
return new ModelAndView(Constants.ERROR_PAGE, model);
}
}

}
#######################DecisionRuleViewController.java#########
package com.tpaic.ruleengine.presentation.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.tpaic.ruleengine.domain.DecisionRule;
import com.tpaic.ruleengine.util.ServiceRequestID;
import com.tpaic.ruleengine.util.Constants;
import com.tpaic.tpfa.app.dto.ActionDTO;
import com.tpaic.tpfa.app.util.StringUtil;
import com.tpaic.tpfa.app.web.AbstractViewController;
import com.tpaic.tpfa.app.web.exception.WebException;

public class DecisionRuleViewController extends AbstractViewController {

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map model = new HashMap();
try {
            String objectId = request.getParameter("ruleId");
            objectId = objectId==null||objectId.trim().equals("")?null:objectId.trim();
            if(objectId==null){
                throw new WebException("无效编号");
            }
            ActionDTO actionDTO = new ActionDTO();
            actionDTO.setOperationType(Constants.ACTION_METHOD_VIEW);
            actionDTO.setObject(objectId);
            DecisionRule obj = (DecisionRule)dispatch.dispatchRequest(actionDTO, ServiceRequestID.DECISION_RULE_ACTION);
            model.put("decisionRule",obj);
return new ModelAndView(this.getFormView(), model);
} catch (Exception e) {
e.printStackTrace();
model = new HashMap();
model.put(Constants.ERROR_MSG, e.getMessage());
model.put(Constants.ERROR_EXCEPTION, StringUtil.getThrowableString(e));
return new ModelAndView(Constants.ERROR_PAGE, model);
}
}

}

#########################end#############





分享到:
评论

相关推荐

    spring 学习

    由于提供的文件内容中存在大量重复的网址信息,并没有实际的教学内容或者相关知识点,我将从标题“spring 学习”出发,结合描述“通过搭建基本的工程,从中学习spring的原理”来详细阐述Spring框架的相关知识点。...

    spring学习资料大全

    以下是对"Spring学习资料大全"的详细解析: 1. **Spring框架基础**: - **依赖注入(Dependency Injection,DI)**:Spring的核心特性之一,它允许开发者在运行时通过XML配置或注解方式来管理对象间的依赖关系,...

    spring学习.zip

    本资源集合围绕"spring学习.zip",提供了多本深入讲解Spring及其相关技术的电子书籍,旨在帮助读者深入理解和掌握Spring生态。 1. **《深入实践Spring Boot.陈韶健.pdf》**:这本书详细介绍了Spring Boot,它是...

    spring学习

    在"spring学习"的资源包中,我们看到三个关于"第四章 Spring的基本用法"的PPT文件,分别是"第一次"、"第三次"和"第二次"。虽然顺序可能有些混乱,但我们可以从中提取出一系列关键知识点。 1. **依赖注入**:Spring...

    Spring学习笔记 自我总结

    spring学习笔记

    spring学习资料,精心总结,不可错过,速领!.zip

    这个"spring学习资料,精心总结,不可错过,速领!.zip"压缩包显然是为那些想要深入理解Spring框架的人准备的。以下是压缩包内可能包含的一些关键知识点,以及它们在实际开发中的应用和重要性: 1. **IoC...

    Spring学习资料文档合集

    Spring学习资料文档合集,包含 spring2.0-reference_RC2.1_zh_cn spring_reference_inchinese_m2 SpringGuide Spring基础教程 spring框架,技术详解及使用指导

    Spring学习笔记&源码

    本资料“Spring学习笔记&源码”是基于网易云课堂黑马程序员的Spring四天精通课程,旨在帮助学习者深入理解和实践Spring框架。 笔记部分可能会涵盖以下内容: 1. **Spring概述**:介绍Spring框架的历史、特点和主要...

    spring学习文档 适合新手

    spring学习文档 适合新手

    spring学习资料

    这个"spring学习资料"压缩包包含了多个文档,可以帮助我们深入理解并掌握Spring的核心概念和技术。 首先,"spring2.0-reference_final_zh_cn.chm"是Spring 2.0的中文参考手册,对于初学者来说非常宝贵。它详细介绍...

    Spring学习思维导图(仅供参考)

    Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图Spring学习思维导图...

    Spring学习笔记.xmind

    Spring学习笔记.xmind

    Spring学习手册

    【Spring学习手册】 Spring框架是Java开发中的一个核心组件,尤其在企业级应用开发中扮演着重要角色。它提供了一种全面的编程和配置模型,旨在简化开发过程并提高可测试性。本手册专为Spring的初学者设计,旨在帮助...

    spring学习文档

    Spring 学习文档 Spring 是一个Java企业级应用程序开发框架,它提供了一个通用的应用程序开发架构,帮助开发者更快速、更高效地开发企业级应用程序。本文档记录了学习 Spring 的过程,包括 Spring 的基础知识、...

    Spring学习笔记+学习源码.zip

    这份"Spring学习笔记+学习源码.zip"资源包含了深入学习Spring及其相关技术的知识点,以及实践代码,对提升Spring技能将大有裨益。 首先,我们来详细讨论Spring框架的主要组件和功能: 1. **依赖注入(Dependency ...

    超好的Spring 学习资料

    "超好的Spring学习资料"这个压缩包显然包含了深入理解并掌握Spring框架的关键资源,尤其是包含的《Spring in Action》这本书,是Spring学习的经典之作。 1. **Spring框架概述**:Spring是一个开源的Java平台,它...

    Spring学习笔记.zip

    根据提供的压缩包文件名,我们可以推测这是一个逐步学习Spring的系列笔记。从"Spring_day1"开始,可能涵盖了Spring的基础概念、环境搭建和基本配置。"Spring_day2"可能涉及了依赖注入和AOP的深入讲解。"Spring_day3...

    Java Spring学习路线.pdf

    上述提到的Spring学习路线涵盖了从基础到高级的多个方面,包括了IOC、AOP、JDBC模板的使用和事务管理等核心内容。掌握这些知识点对于高效开发高质量的Java后端应用至关重要。对于Java后台开发人员而言,深入学习和...

Global site tag (gtag.js) - Google Analytics