web开发中Velocity的应用

跟大学同学从去年开始一起搞的softecase项目差不多完成了。在页面模版选择方面,我们选择了velocity来做公共界面设计。大家知道,当Velocity应用于web开发时,界面设计者可以和程序开发者同步开发一个遵循MVC架构的web站点,这就是说,页面设计者可以只关注页面的显示效果,程序开发者关注业务逻辑编码。

下面是表格编辑及预览的模版:

CLASSIC_EDITOR_TABLE.vm 代码
  1. <HTML>  
  2. <HEAD>  
  3. <TITLE>$logixBox.getCaption()</TITLE>  
  4. <META HTTP-EQUIV="Content-Type"   CONTENT="text/html; CHARSET=GBK"></META>  
  5.   
  6. #foreach( $scriptFile in $logixBox.getBoxController().getScriptFilesOfLoadAtStart())   
  7.     <script src="$scriptFile.getFileName()"></script>  
  8. #end   
  9. #foreach( $linkFile in $logixBox.getBoxController().getLinkFiles())   
  10.     <link type="text/css" rel="StyleSheet" href="$linkFile" />  
  11. #end   
  12.   
  13.     <link type="text/css" rel="StyleSheet" href="softecase/style/classic/logixGrid.css" />  
  14. </HEAD>  
  15.   
  16.   
  17. <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="bodyBorder">  
  18.   
  19.   
  20. <table id="bodyTable" border="0" cellspacing="0" cellpadding="0" height="100%" width="100%">  
  21. <tr><td height="30">  
  22.   
  23. #set ($flag=$logixBox.getBoxParam().getRequestParam("STANDARD_IDENTITY"))   
  24.   
  25. #if (!$flag)   
  26.     #set ($flag="表格新建")   
  27. #else   
  28.     #set ($flag="表格编辑")   
  29. #end   
  30. <div class="mainCaption">$logixBox.getCaption()--$flag</div>  
  31.   
  32. </td></tr>  
  33. <tr><td height="22">  
  34.   
  35. <div id="tabController" onselectstart="event.returnValue = false;">  
  36.     <div id="tabCaption_1" style="display:inline" class="tabCaptionSelected">基本信息</div>  
  37. </div>  
  38.   
  39.   
  40. </td></tr>  
  41.   
  42.   
  43.   
  44. <tr><td width="100%" valign="top" >  
  45. <div id="divContent" style="OVERFLOW: auto; height: 100%; width: 100%" onresize="this.style.width = document.body.clientWidth;" class="clientBG">  
  46.   
  47.     <div id="tab_1" style="display:block" class="tabContent">  
  48.   
  49.     <div id = "controller" align="left" class="multiBar">  
  50.         <button id="_addRow" onclick="_addRow()" class="buttonStyle" onmouseover='commonMouseOver()' onmouseout='commonMouseOut()'>增加一行</button>  
  51.         <button id="_removeRow" onclick="_removeRow()" class="buttonStyle" onmouseover='commonMouseOver()' onmouseout='commonMouseOut()'>删除所选行</button>  
  52.         <button id="_post" onclick="_doPost()" class="buttonStyle" onmouseover='commonMouseOver()' onmouseout='commonMouseOut()'>保存</button>  
  53.         <button id="back" onclick="javascript:showChildNavWindow(window.parent)" class="buttonStyle" onmouseover='commonMouseOver()' onmouseout='commonMouseOut()'>返回</button>  
  54.     </div>  
  55.   
  56.   
  57.     #set($root=$logixBox.generateWebViewData())   
  58.   
  59.     <form name="form0" method="post" action="persist.exec" colsDef="$root.getType()">  
  60.   
  61.     #set ($headerSet=$root.getChildren().get(0))   
  62.     #set ($rowSet=$root.getChildren().get(2))   
  63.   
  64.     <div id="logixGrid" style="behavior:url(softecase/style/classic/logixGrid.htc);width:100%;height:100%;padding-left:2px;">  
  65.         <div type="FIXEDPART" class="FIXED_PART_STYLE">  
  66.             <div type="HEADERS" class="FIXED_HEADERS_STYLE">  
  67.                 #set ($tmpIndex = 0 )   
  68.                 #foreach ($header in $headerSet.getChildren())   
  69.                     #if ($tmpIndex < $root.getFixedColumnCount())   
  70.                         #set ($isRequired = $header.getData().get(4))   
  71.                         #set ($visibleValue=$header.getData().get(3))   
  72.   
  73.                         #set ($headerColor = "#FFFFFF")   
  74.                         #if ($isRequired=="1")   
  75.                             #set ($headerColor = "#FF0000")   
  76.                         #end   
  77.   
  78.                         #set ($visibleWidth = $header.getData().get(5))   
  79.   
  80.                         #set ($realValue = $header.getData().get(6))   
  81.                         #set ($dispValue = $header.getData().get(7))   
  82.   
  83.                         <div align="center" id="$header.getData().get(0)" style = "color:$headerColor;width:$visibleWidth ex;"  
  84.                             realValue = "$realValue" dispValue = "$dispValue" title="$header.getData().get(8)" class="FIXED_HEADER_STYLE"  
  85.                             isRequired = "$isRequired" propType="$header.getData().get(2)" visibleValue="$visibleValue">  
  86.                             $header.getData().get(1)   
  87.                         </div>  
  88.                     #end   
  89.                     #set ($tmpIndex = $tmpIndex + 1 )   
  90.                 #end   
  91.             </div>  
  92.   
  93.             <div type="ROWS" class="FIXED_ROWS_STYLE">  
  94.                 #foreach ($row in $rowSet.getChildren())   
  95.                     <div type="ROW" >  
  96.                         #set ($tmpIndex = 0 )   
  97.                         #foreach ($cell in $row.getChildren())   
  98.                             #if ($tmpIndex < $root.getFixedColumnCount())   
  99.                                 #set ($visibleValue=$cell.getData().get(1))   
  100.   
  101.                                 #set ($realValue = $cell.getData().get(2))   
  102.                                 #set ($dispValue = $cell.getData().get(3))   
  103.                                 <div id="$cell.getData().get(0)" realValue = "$realValue" visibleValue="$visibleValue" class="FIXED_CELL_STYLE">$dispValue</div>  
  104.                             #end   
  105.                             #set ($tmpIndex = $tmpIndex + 1 )   
  106.                         #end   
  107.                     </div>  
  108.                 #end   
  109.             </div>  
  110.         </div>  
  111.         <div type="DYNAMICPART" class="DYNAMIC_PART_STYLE">  
  112.             <div type="HEADERS" class="DYNAMIC_HEADERS_STYLE">  
  113.                 #set ($tmpIndex = 0 )   
  114.                 #foreach ($header in $headerSet.getChildren())   
  115.                     #if ($tmpIndex >= $root.getFixedColumnCount())   
  116.                         #set ($isRequired = $header.getData().get(4))   
  117.   
  118.                         #set ($visibleValue=$header.getData().get(3))   
  119.   
  120.                         #set ($headerColor = "#FFFFFF")   
  121.                         #if ($isRequired=="1")   
  122.                             #set ($headerColor = "#FF0000")   
  123.                         #end   
  124.   
  125.                         #set ($visibleWidth = $header.getData().get(5))   
  126.   
  127.                         #set ($realValue = $header.getData().get(6))   
  128.                         #set ($dispValue = $header.getData().get(7))   
  129.   
  130.                         <div align="center" id="$header.getData().get(0)" style = "color:$headerColor;width:$visibleWidth ex;"  
  131.                             realValue = "$realValue" dispValue = "$dispValue" title="$header.getData().get(8)" class="DYNAMIC_HEADER_STYLE"  
  132.                             isRequired = "$isRequired" propType="$header.getData().get(2)" visibleValue="$visibleValue">  
  133.                             $header.getData().get(1)   
  134.                         </div>  
  135.                     #end   
  136.                     #set ($tmpIndex = $tmpIndex + 1 )   
  137.                 #end   
  138.             </div>  
  139.             <div type="ROWS" class="DYNAMIC_ROWS_STYLE">  
  140.                 #foreach ($row in $rowSet.getChildren())   
  141.                     <div type="ROW" >  
  142.                         #set ($tmpIndex = 0 )   
  143.                         #foreach ($cell in $row.getChildren())   
  144.                             #if ($tmpIndex >= $root.getFixedColumnCount())   
  145.                                 #set ($visibleValue=$cell.getData().get(1))   
  146.                                 #set ($realValue = $cell.getData().get(2))   
  147.                                 #set ($dispValue = $cell.getData().get(3))   
  148.                                 <div id="$cell.getData().get(0)" realValue = "$realValue" visibleValue="$visibleValue" class="DYNAMIC_CELL_STYLE">$dispValue</div>  
  149.                             #end   
  150.                             #set ($tmpIndex = $tmpIndex + 1 )   
  151.                         #end   
  152.                     </div>  
  153.                 #end   
  154.             </div>  
  155.         </div>  
  156.     </div>  
  157.   
  158.   
  159.   
  160.             <input id="_data" type="hidden" name="LOGIXBOX_NAME" value="$logixBox.getBoxName()"/>  
  161.             #set ($identity=$logixBox.getBoxParam().getRequestParam("STANDARD_IDENTITY"))   
  162.             #if (!$identity)   
  163.                 #set ($identity="")   
  164.             #end   
  165.             <input id="_data" type="hidden" name="STANDARD_IDENTITY" value="$identity"/>  
  166.   
  167.             #set ($identity=$logixBox.getBoxParam().getRequestParam("PARENT_IDENTITY"))   
  168.             #if (!$identity)   
  169.                 #set ($identity="")   
  170.             #end   
  171.   
  172.             #set ($isRoot=$logixBox.getBoxParam().getRequestParam("IS_ROOT"))   
  173.             #if (!$isRoot)   
  174.                 #set ($isRoot="")   
  175.             #end   
  176.   
  177.             <input id="_data" type="hidden" name="PARENT_IDENTITY" value="$identity"/>  
  178.             <input id="_data" type="hidden" name="IS_ROOT" value="$isRoot"/>  
  179.             <input id="_data" type="hidden" name="LOGIX_STATUS" value="$logixBox.getBoxParam().getStatus().toString()"/>  
  180.             <input id="_data" type="hidden" name="LOGIX_SCENE" value="$logixBox.getBoxParam().getScene().toString()"/>  
  181.             <input id="_data" type="hidden" name="LOGIX_PARTTYPE" value="$logixBox.getBoxParam().getPartType().toString()"/>  
  182.             <input id="_data" type="hidden" name="LOGIX_LAYOUT" value="$logixBox.getBoxParam().getLayout().toString()"/>  
  183.             <input id="_data" type="hidden" name="LOGIX_SELECTMODE" value="$logixBox.getBoxParam().getSelectMode().toString()"/>  
  184.             <input id="_data" type="hidden" name="LOGIX_OPERATE" value="$logixBox.getBoxParam().getOperateType().toString()"/>  
  185.   
  186.             #set ($multiIndex=$logixBox.getBoxParam().getMultiIndex())   
  187.             #set ($selectCount=$logixBox.getBoxParam().getSelectCount())   
  188.   
  189.             <input id="_data" type="hidden" name="MULTI_INDEX" value="$multiIndex" />  
  190.             <input id="_data" type="hidden" name="SELECT_COUNT" value="$selectCount" />  
  191.     </form>  
  192.     </div>  
  193. </div>  
  194.   
  195.     <div id ="editContentSet" style="display:none;">  
  196.             #set ($editContentSet=$root.getChildren().get(1))   
  197.             #foreach ($editContent in $editContentSet.getData())   
  198.                 <div>$editContent</div>  
  199.             #end   
  200.     </div>  
  201. </td></tr>  
  202.   
  203. </table>  
  204.   
  205.   
  206. </body>  
  207.   
  208.   
  209.     <script >  
  210.         if (controller!=null&&form0.STANDARD_IDENTITY.value!=""){   
  211.             var tmp = controller.all.item("_addRow");   
  212.             if (tmp!=null){   
  213.                 tmp.style.display = "none";   
  214.             }   
  215.             tmp = controller.all.item("_removeRow");   
  216.             if (tmp!=null){   
  217.                 tmp.style.display = "none";   
  218.             }   
  219.         }   
  220.     </script>  
  221.     <script src="softecase/script/logixGrid.js"></script>  
  222. #foreach( $scriptFile in $logixBox.getBoxController().getScriptFilesOfLoadAtEnd())   
  223.     <script src="$scriptFile.getFileName()"></script>  
  224. #end   
  225. </HTML>  

 

CLASSIC_NAVIGATOR_TABLE.vm
  1. <HTML<spa>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值