struts2中action如何获得<s:optiontransferselect />的值

jiang0723 2008-10-15
jsp中的<s:optiontransferselect />标签已正常显示使用
<s:optiontransferselect tooltip="用户权限" label="设置权限"
name="mhPopedom.leftList_1"
leftTitle="用户未授权限"
list="leftList_1"
listKey="popeId"
listValue="popeName"
headerKey="headerKey"
multiple="true"
emptyOption="false"
allowUpDownOnLeft="false"
cssStyle="width:200px;height:300px;"
cssClass="input2"

addToLeftLabel="向左移动"
addToRightLabel="向右移动"
addAllToLeftLabel="全部左移"
selectAllLabel="全部选择"
addAllToRightLabel="全部右移"

doubleName="rightPopedom"
rightTitle="用户已授权限"
doubleList="rightList_1"
doubleListKey="popeId"
doubleListValue="popeName"
doubleHeaderKey="doubleHeaderKey"
doubleMultiple="true"
doubleEmptyOption="false"
allowUpDownOnRight="false"
doubleCssClass="input2"
doubleCssStyle="width:200px;height:300px;">
</s:optiontransferselect>
但不论怎样在action中都不能获得rightPopedom的值,报空指针异常。
请各位帮忙,在线急等!!!!
flybida 2009-07-28
后台action里面添加属性(setXXX和getXXX方法):
private String[] leftList;
private String[] rightList;

在前台页面上,当提交表单时,onclick事件调用下面的js:
<script type="text/javascript">
  function myself(){
  var right=document.forms[0].rightList;
  for(i=1; i <right.length; i++)
    right[i].selected = true;
  }
</script>
提交后,就能在后台得到rightList里面的值了。
如果没有这段Js代码,后台是得不到值的,这是Struts2 <s:optiontransferselect/>本身的bug.
hukkkk 2009-08-24
很好,在form中使用<s:submit/>也能够取到值
Global site tag (gtag.js) - Google Analytics