DWZ的URL变量替换

在DWZ文档中,对URL的变量替换说明如下:

HTML扩展方式navTab, dialog, ajaxTodo的url支持变量替换。例如:__URL__/edit/id/{xxx},大括号内的xxx就是变量名,主要功能是结合table组件一起使用,利用URL变量替换,对于解决数据的删除、编辑是非常方便的。

比如:删除、编辑使用了变量{sid_user}

<tbody>中<tr target="sid_user"rel="{$vo['id']}">

当选中一行时,tr上的rel值会自动替换到url变量中.

注意url变量名{sid_user}和tr的target="sid_user"保持一致.

具体的URL变量替换使用如下:

继续之前DWZ笔记二的例子,客户信息管理的界面如下:

《DWZ笔记四》URL变量替换 - heavengate - Heavengate的博客

 

界面代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <base href="<%=basePath%>">

<%@taglib uri="/struts-tags"  prefix="s" %>

<!--分页的form-->

<form id="pagerForm" action="<%=basePath%>/admin/customer_main.action" method="post">       <input type="hidden" name="pageNum" value="1" /><!--【必须】value=1可以写死-->       <input type="hidden" name="numPerPage" value="${param.numPerPage}" />--> </form>

<div class="pageHeader">

<!--查询的form-->  <form  rel="pageForm"  οnsubmit="return navTabSearch(this);"  action="<%=basePath%>/admin/customer_main.action" method="post">    <div class="searchBar">   <ul class="searchContent">    <li>     <label>我的客户:</label>     <input name="keywords" type="text" size="25" value="${param.keywords}" alt="请输入客户名"/>    </li>      </ul>     <div class="subBar">    <ul>     <li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>     <li><a class="button" href="demo_page6.html" target="dialog" mask="true" title="查询框"><span>高级检索</span></a></li>    </ul>   </div>  </div>  </form> </div>

<div class="pageContent">  <div class="panelBar">   <ul class="toolBar">       <li><input type="checkbox" class="checkboxCtrl" group="ids" />全选</li>       <li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=basePath%>/admin/customer_deleteAll.action" class="delete"><span>批量删除</span></a></li>    <li><a class="add" href="<%=basePath%>/admin/customer_addInput.jsp" target="navTab"><span>添加</span></a></li>    <li><a class="delete" href="customer_delete.action?customer.id={cid}" target="ajaxTodo" title="确定要删除吗?"><span>删除</span></a></li>    <li><a class="edit" href="customer_updateInput.action?id={cid}" target="navTab"><span>修改</span></a></li>    <li class="line">line</li>    <li><a class="icon" href="demo/common/dwz-team.xls" target="dwzExport" targetType="navTab" title="实要导出这些记录吗?"><span>导出EXCEL</span></a></li>   </ul>  </div>  <table class="table" width="100%" layoutH="150">   <thead>    <tr>                 <th width="50">选择</th>     <th width="120">序号</th>     <th>客户昵称</th>     <th width="100">客户名</th>     <th width="150">客户类型</th>     <th width="80" align="center">客户状态</th>     <th width="80">客户邮箱</th>     <th width="80">创建时间</th>     <th width="80">上次登录时间</th>     <th width="80">上次登录IP</th>    </tr>   </thead>   <tbody>   <s:iterator value="customers" var="c">      <tr target="cid" rel="${c.id}">          <td><input type="checkbox" name="ids" value="${c.id}" /></td>          <td>${c.id}</td>          <td>${c.cus_id}</td>          <td>${c.cus_name}</td>          <td><s:if test='#c.cus_type=="2"'>普通客户</s:if><s:else>管理员</s:else></td>          <td><s:if test='#c.cus_isLock=="0"'>正常使用</s:if><s:else>用户锁定</s:else></td>          <td>${c.cus_email}</td>          <td>${c.cus_createtime}</td>          <td>${c.last_logintime}</td>          <td>${c.last_loginip}</td>      </tr>     </s:iterator>   </tbody>  </table>  <div class="panelBar">   <div class="pages">    <span>显示</span>    <select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">     <option value="20">20</option>     <option value="10">10</option>     <option value="30">30</option>     <option value="500">50</option>     <option value="100">100</option>    </select>    <span>条,共${pager.totalCount}条</span>   </div>   <!--分页组件-->   <div class="pagination" targetType="navTab" totalCount="${pager.totalCount}" numPerPage="${pager.everyPage}" pageNumShown="10" currentPage="${pager.currentPage}"></div>

 </div>   </div>

在上述代码中,对于删除和编辑的按钮设置如下:

 <li>

<a class="delete" href="customer_delete.action?customer.id={cid}" target="ajaxTodo"

title="确定要删除吗?"><span>删除</span></a>

</li> <li><a class="edit" href="customer_updateInput.action?id={cid}" target="navTab"><span>修改</span></a></li>

 
其中定义的XXX?id{cid}中的cid即为需要替换的变量,其具体定义在table中:

  <table class="table" width="100%" layoutH="150">   <thead>    <tr>                 <th width="50">选择</th>     <th width="120">序号</th>     <th>客户昵称</th>     <th width="100">客户名</th>     <th width="150">客户类型</th>     <th width="80" align="center">客户状态</th>     <th width="80">客户邮箱</th>     <th width="80">创建时间</th>

    <th width="80">上次登录时间</th>     <th width="80">上次登录IP</th>    </tr>   </thead>   <tbody>   <s:iterator value="customers" var="c">      <tr target="cid" rel="${c.id}">          <td><input type="checkbox" name="ids" value="${c.id}" /></td>          <td>${c.id}</td>          <td>${c.cus_id}</td>          <td>${c.cus_name}</td>          <td><s:if test='#c.cus_type=="2"'>普通客户</s:if><s:else>管理员</s:else></td>          <td><s:if test='#c.cus_isLock=="0"'>正常使用</s:if><s:else>用户锁定</s:else></td>          <td>${c.cus_email}</td>          <td>${c.cus_createtime}</td>          <td>${c.last_logintime}</td>          <td>${c.last_loginip}</td>      </tr>     </s:iterator>   </tbody>  </table>

在这个table中,通过<s:iterator value="customers" var="c">,利用strut的标签,将后台的customer信息打印在页面中,同时进行关键设置<tr target="cid" rel="${c.id}">,当选中某一行时,rel="${c.id}"中的rel的值将自动替换到cid中,即通过target="cid"定义,也就是替换进删除和编辑的变量中。

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值