webwork 类型转换器的使用

jsp页面,表单提交页面:表单提交数组至action的中vo中。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=gbk" pageEncoding="GBK" %>
<%@ page isELIgnored="false"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../head.jsp" %>
<script src="/js/Check.js"></script>
<Script>
function onSaveNew(){
	if (checkElements(document.frmMain) == "N") {
			return;
		} else {
           document.frmMain.action="/mgmt/product/hotel/hotelSetHeb.action?type=save";
           document.frmMain.submit();
     }
}

var fssCount = 0;
function addFssRow(){
    fssCount++;
    var fssTable = document.getElementById("fssTable");
    var fssRow = fssTable.insertRow(fssTable.rows.length);
    var fssCell = fssRow.insertCell(fssRow.cells.length);
    var cellHtml = "<input type='hidden' name='hremList("+fssCount+").index' id='hremList("+fssCount+").index' value='"+fssCount+"'/>";
    cellHtml += " 利润空间区间:<input type='text' name='hremList("+fssCount+").hremBegin' id='hremList("+fssCount+").hremBegin'   class='inputbox btn_d'/>  ";
    cellHtml += "<input type='text' name='hremList("+fssCount+").hremEnd' id='hremList("+fssCount+").hremEnd'  class='inputbox btn_d' /> ";
    cellHtml += "留:<input type='text' name='hremList("+fssCount+").hremDot' id='hremList("+fssCount+").hremDot'  class='inputbox btn_d' />%";
    cellHtml += "<a href='javascript:void(0)' οnclick='delFssRow(this)'> 删除</a>";
    fssCell.innerHTML = cellHtml;
}
function delFssRow(obj){
    var fssRow = obj.parentNode.parentNode;
    var fssTable = document.getElementById("fssTable");
    fssTable.deleteRow(fssRow.rowIndex);
}
</script>
</head>

<body >
<!--head end-->
<form name="frmMain" id="frmMain" method="post">
<div id="container">
            <h2><span class="menu_help">您现在的位置:产品管理 >> 酒店 >> 新增</span>
            <a href="/mgmt/product/hotel/hotelSupplyList.action" class="menu_off"><span>酒店</span></a>
            <a href="/mgmt/product/hotel/hotel.action" class="menu_off"><span>房型管理</span></a>
            <a class="menu_on"><span>接口设置</span></a></h2>
				
	<div class="main">            	   
	 	 <div class="table_list_content">
			  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_detail">
			  <tr><th> </th><td class="bold">接口设置</td></tr>
			   <tr>
			    <th><span class="red">*</span>商户号:</th>
			    <td><input type="text" name="cno" id="cno" value="${cno}" eleName="商户号" checkValue="eLength:50;"  class="inputbox btn_c" />
			     请确保您的商户号、账户、密钥的正确性!</td>
			  </tr>
			  <tr>
			    <th><span class="red">*</span>帐户:</th>
			    <td><input type="text" name="hln" id="hln" value="${hln}" eleName="帐户" checkValue="eLength:50;"  class="inputbox btn_c" />
			     </td>
			  </tr>
			  <tr>
			    <th width="15%"><span class="red">*</span>密钥:</th>
			    <td width="85%"><textarea name="hpw"  class="inputbox" id="hpw" eleName="密钥" checkValue="eLength:100;" cols="60" rows="4">${hpw}</textarea></td>
			  </tr>
			  <tr>
                                <th>
                                    <span class="red">*</span>流润百分比:
                                </th>
                                <td>
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0"
                                        class="fanTable" id="fssTable">
                                        <c:choose>
                                            <c:when test="${empty hremList}">
                                                <tr>
                                                    <td>
                                                        <input type="hidden" name="hremList(0).index"
                                                            id="hremList(0).index" value="0" />
                                                        利润空间区间:
                                                        <input type="text" name="hremList(0).hremBegin"
                                                            id="hremList(0).hremBegin" class='inputbox btn_d' />
                                                         
                                                        <input type="text" name="hremList(0).hremEnd"
                                                            id="hremList(0).hremEnd" class='inputbox btn_d' />
                                                        留:
                                                        <input type="text" name="hremList(0).hremDot"
                                                            id="hremList(0).hremDot" class='inputbox btn_d' />
                                                        %
                                                        <a href="javascript:void(0)"
                                                            οnclick="addFssRow();parent.SetCwinHeight();">新增</a>
                                                    </td>
                                                </tr>
                                            </c:when>
                                            <c:otherwise>
                                                <c:forEach items="${hremList}" var="hremList" varStatus="vs">
                                                    <tr>
                                                        <td>
                                                            <input type="hidden" name="hremList(${vs.index }).index"
                                                                id="hremList(${vs.index }).index" value="${vs.index }" />
                                                            利润空间区间:
                                                            <input type="text" value="${hremList.hremBegin }"
                                                                name="hremList(${vs.index }).hremBegin"
                                                                id="hremList(${vs.index }).hremBegin"
                                                                class='inputbox btn_d' />
                                                             
                                                            <input type="text" value="${hremList.hremEnd }"
                                                                name="hremList(${vs.index }).hremEnd"
                                                                id="hremList(${vs.index }).hremEnd"
                                                                class='inputbox btn_d' />
                                                            留:
                                                            <input type="text" value="${hremList.hremDot }"
                                                                name="hremList(${vs.index }).hremDot"
                                                                id="hremList(${vs.index }).hremDot"
                                                                class='inputbox btn_d' />
                                                            %

                                                            <c:choose>
                                                                <c:when test="${vs.index==0}">
                                                                    <a href="javascript:void(0)"
                                                                        οnclick="addFssRow();parent.SetCwinHeight();">新增</a>
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <a href="javascript:void(0)"
                                                                        οnclick="delFssRow(this);parent.SetCwinHeight();">删除</a>
                                                                    <script>fssCount++;</script>
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </td>
                                                    </tr>
                                                </c:forEach>
                                            </c:otherwise>
                                        </c:choose>

                                    </table>
                                    <span style="color: red"> 注:  利润空间 =
                                        参考价-结算价</span>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <span class="red">*</span>无参考价:
                                </th>
                                <td>
                                    加价:
                                    <input class="inputbox" size="5" type="text" name="hnop"
                                        id="hnop" value="${hnop }" />
                                    %
                                    <br />

                                </td>
                            </tr>
			</table>
			
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="btnTable">
			  <tr>
			    <td><button type="button" class="press_button_a" οnclick="onSaveNew();">保 存</button></td>
			  </tr>
			</table>				      
		</div><!--表格-->
	</div>
</div><!--container end-->

</form>
</body>
</html>
2. vo:ProductInitVo.java中的需要转换的类型hotelHremVo.
private List<FakeSeatSetVo> fssList = new ArrayList<FakeSeatSetVo>();//虚位设置
	private List<HotelHremVo>   hremList = new ArrayList<HotelHremVo>();  //留润

public List<HotelHremVo> getHremList() {
		return hremList;
	}
	public void setHremList(List<HotelHremVo> hremList) {
		this.hremList = hremList;
	}


并在ProductInitVo.java的相同目录下穿件配置文件ProductInitVo-conversion.properties:


Element_hremList=com.bbcmart.action.mgmt.product.hotel.vo.HotelHremVo  (需要转换的类如2中的“留润”类型)
CreateIfNull_hremList=true    (没有就创建一个list)
KeyProperty_hremList=index   




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值