页面中取得<s:select>选择后的单个值

本文介绍了一种在JSP页面中显示从Map获取的选择值的方法。通过使用内嵌的表达式,可以从传递过来的Map中取出指定键的值并显示。

在JSP页面中有时候会用到显示选择后的单个值,如此取得还是比较方便的。

sexMap:action类中对应的Map

<%= ((java.util.Map) request.getAttribute("sexMap")).get(request.getAttribute("model.sex")) %>

请详细分析下面代码: <#import "/decorators/includes/macros.ftl" as m> <#assign ww = JspTaglibs["/WEB-INF/webwork.tld"] /> <#include "/template/includes/actionerrors.ftl"> <script> xmlParse = new function(){ this.xmlDoc = null; this.parse=function(response){ this.xmlDoc = response.responseXML.documentElement; } //取得所有节点 this.getRows=function(_xpath){ return this.xmlDoc.selectNodes(_xpath); } //取得单个节点 this.getRow=function(_xpath){ return this.xmlDoc.selectSingleNode(_xpath); } //取得单个节点的文本 this.getRowValue=function(_xpath){ return this.xmlDoc.selectSingleNode(_xpath).text; } //取得属性 this.getRowAttribute=function(_rowItem,attr){ var xpath="@"+attr; return _rowItem.selectSingleNode(xpath).text; } } function checkRuncardStatus(){ var url ="checkFormData.action"; var ajaxRequest = new Ajax.Request( url,{ method: 'post', asynchronous: 'false', parameters: $('requestFormId').serialize(), onComplete: function(transport){ //alert(transport.responseText); xmlParse.parse(transport); var status =xmlParse.getRows("/roots/status"); var flag=status[0].getAttribute("value"); //alert(xmlParse.getRowValue("/roots/status")); if(flag=="nodraft"){ alert("This runcard had been issued, don't click the button of back off in the browser.\n\n Please apply new application !"); } }}); } function checkPageToPreview(){ var form = document.forms['updateRequestForm']; var holdStepNo=form.elements["requestForm.holdStepNo"]; var ercStepNo=form.elements["requestForm.ercStepNo"]; var holdStepNoMes=form.elements["requestForm.holdStepNoMes"]; var ercStepNoMes=form.elements["requestForm.ercStepNoMes"]; clearHoldLotInfo(holdStepNo); clearCompleteLotInfo(ercStepNo); /* remove the Lot Type check. var lotType="${requestForm.lotType?default('')?if_exists}"; var runcardCategory=$F("requestForm.ercCategory"); if(lotType=="P" | lotType=="R" | lotType=="M" |lotType=="B" |lotType=="E1" |lotType=="E2"|lotType=="E3" |lotType=="E9"){ if(runcardCategory!="Input the STR Number" && runcardCategory!="STR" && runcardCategory!="MSTR" ) { alert("Because the lotType is "+lotType+ ". Please select 'the For STR/MSTR lots(Pls input the effective STR or MSTR number)' in RunCard Category, and input the STR# ! "); $("requestForm.ercCategory").focus(); return false; } }*/ if (typeof form.elements["requestForm.lotId"]!= "undefined"){ var element = form.elements["requestForm.lotId"].value; if (element==""){ alert("The Lot field can not be null"); form.elements["requestForm.lotId"].focus(); return false; } } if (typeof form.elements["requestForm.ercRunMode"]!= "undefined"){ if (!form["requestForm.ercRunMode"][0].checked&&!form["requestForm.ercRunMode"][1].checked){ alert("Please choose the Runcard's Follow mode after Runcard completed!"); return false; } } if (typeof form.elements["requestForm.needCheck"]!= "undefined"){ if (!form["requestForm.needCheck"][0].checked&&!form["requestForm.needCheck"][1].checked){ alert("Please choose the check RunCard's Product Id method!"); return false; } } if (typeof form.elements["requestForm.holdStepNo"]!= "undefined"){ var element = form.elements["requestForm.holdStepNo"].value; if (element==""){ alert("The Hold Step No field can not be null"); form.elements["requestForm.holdStepNo"].focus(); return false; } var elementMes = form.elements["requestForm.holdStepNoMes"].value; if (elementMes==null || element!=elementMes){ alert("Please click [go] to get MES information."); form.elements["requestForm.holdStepNo"].focus(); return false; } } if (typeof form.elements["requestForm.holdStepNo"]!= "undefined"){ var element = form.elements["requestForm.holdStepNo"].value; if (element==""){ alert("The Hold Step No field can not be null"); form.elements["requestForm.holdStepNo"].focus(); return false; } } if (typeof form.elements["requestForm.relatedModlue"]!= "undefined"){ var element = form.elements["requestForm.relatedModlue"].value; if (element==""){ alert("You must select related module manager to sign runcard"); form.elements["requestForm.relatedModlue"].focus(); return false; } } if (typeof form.elements["requestForm.E1Mgr"]!= "undefined"){ var element = form.elements["requestForm.E1Mgr"].value; if (element==""){ alert("You must select E1 manager to sign runcard"); form.elements["requestForm.E1Mgr"].focus(); return false; } } if (typeof form.elements["requestForm.mfgMgr"]!= "undefined"){ var element = form.elements["requestForm.mfgMgr"].value; if (element==""){ alert("You must select MFG manager to sign runcard"); form.elements["requestForm.mfgMgr"].focus(); return false; } } if (typeof form.elements["requestForm.ercCategory"]!= "undefined"){ var element = form.elements["requestForm.ercCategory"].value; if (element=="Please Select"){ alert("You must select Runcard Category!"); form.elements["requestForm.ercCategory"].focus(); return false; } } if (typeof form.elements["requestForm.purpose"]!= "undefined"){ var element = form.elements["requestForm.purpose"].value; if(element.length>150){ alert("Remark最多150个字符!"); element.focus(); return false; } if (element==""){ alert("Purpose can not be null!"); form.elements["requestForm.purpose"].focus(); return false; } } if (typeof form.elements["requestForm.strEnNo"]!= "undefined"){ var element = form.elements["requestForm.strEnNo"].value; if (element==""){ if(form.elements["requestForm.ercCategory"].value=="For Customer Request") alert("EN#. can not be null!"); else alert("STR NO#. can not be null!"); form.elements["requestForm.strEnNo"].focus(); return false; } } if (typeof form.elements["requestForm.ercContamination"]!= "undefined"){ var element = form.elements["requestForm.ercContamination"].value; if (element=="Please Select"){ alert("Please select Lot Contamination Flag!"); form.elements["requestForm.ercContamination"].focus(); return false; } } if (typeof form.elements["requestForm.ercStepNo"]!= "undefined"){ var element = form.elements["requestForm.ercStepNo"].value; if (element==""){ alert("Step No#. can not be null!"); form.elements["requestForm.ercStepNo"].focus(); return false; } var elementMes = form.elements["requestForm.ercStepNoMes"].value; if (elementMes==null || element!=elementMes){ alert("Please click [go] to get MES information."); form.elements["requestForm.ercStepNo"].focus(); return false; } } if (typeof form.elements["requestForm.ercEngineerNo"]!= "undefined"){ var element = form.elements["requestForm.ercEngineerNo"].value; if (element==""){ alert("Engineer can not be null!"); form.elements["requestForm.ercEngineerNo"].focus(); return false; } } if (typeof form.elements["requestForm.ercEngineerTel"]!= "undefined"){ var element = form.elements["requestForm.ercEngineerTel"].value; if (element==""){ alert("Engineer Tel. can not be null!"); form.elements["requestForm.ercEngineerTel"].focus(); return false; } } <#if requestForm.formType=="Normal" || requestForm.formType=="Auto Reposition Step"> var wHeight=400; var wWidth=620; var wTop=(screen.height-wHeight)/2; var wLeft=(screen.width-wWidth)/2; var str=window.showModalDialog("stepCompareRule.action?requestFormId=${requestForm.id}","","dialogTop:"+wTop+"px; dialogLeft:"+wLeft+"px;dialogheight :"+wHeight+"px; dialogwidth :"+wWidth+"px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:Yes;"); if(str=="null" || str==undefined || str!="Yes"){ return false; } </#if> form.action="updateRequestForm.action"; form.submit(); } </script> <#if requestForm.status!="DRAFT"><div><font color="red">This runcard had been issued.If you want to apply the case,please click the new application.</font></div></#if> <#if requestForm.haveQtime?has_content><div><font color="red">This runcard information had been stored the MES.If you want to delete this runcard,please click the button(Prview and Cancel Runcard ).If you want to submit it,please click the button (Preview and Continue Runcard)</font></div></#if> <#if (requestForm.match)?default("")=="N"><div>Compare with MES Result:  <font color="red">Not match MES Info</font></div><#elseif (requestForm.match)?default("")=="Y"> <div>Compare with MES Result:  <font color="red">Match MES Info</font></div><#else><div>Compare with MES Result:  <font color="red">${requestForm.match?default("")}</font></div> </#if> <div class="app"> <h3>e-Runcard Request Form(${requestForm.formType?if_exists})</h3> <form name="updateRequestForm" action="updateRequestForm.action" namespace="/user" method="post"> <@ww.hidden name="'requestFormId'" value="${requestForm.id}"/> <@ww.hidden name="'requestForm.match'" value="'No Comparison'"/> <@ww.hidden name="'requestForm.compareResultComment'" value="''"/> <@ww.hidden name="'requestForm.holdStepNoMes'"/> <@ww.hidden name="'requestForm.ercStepNoMes'"/> <input type="hidden" name="paginationSupport.startIndex" value="0"/> <input type="hidden" name="paginationSupport.countOnEachPage" value="10"/> <table border="0" cellspacing="1" cellpadding="8" width="100%"> <tr class="b"> <td>RunCard No.:</td> <td>${requestForm.caseNo?if_exists}</td> <td>Status:</td> <td><font color="red">${requestForm.status?if_exists}</font></td> </tr> <tr class="b"> <td>Applicant:</td> <td><@m.directoryLink requestForm.applicant?if_exists/> </td> <td>Organization:</td> <td>${requestForm.applicantOrg?if_exists}</td> </tr> <tr class="b"> <td>Submit Date:</td> <td>${requestForm.submitDate?if_exists}</td> <td>Effective Date:</td> <td>${requestForm.effectiveDate?if_exists}</td> </tr> <#switch requestForm.formType> <#case "Auto Reposition Step"> <#include "includeLotInfo.ftl"/> <#include "includeSignInfo.ftl"/> <#include "includeErcHeaderInfo_reposition.ftl"/> <#include "includeErcCompleteInfo.ftl"/> </table> <#break> <#default> <#include "includeLotInfo.ftl"/> <#include "includeSignInfo.ftl"/> <#include "includeErcHeaderInfo.ftl"/> <#include "includeErcCompleteInfo.ftl"/> </table> <table border="0" cellspacing="1" cellpadding="8" width="100%"> <#assign showWGRbtn="true"/> <#include "includeStepInfo.ftl"/> </table> </#switch> <#if requestForm.lotCategory?exists> <table border="0" cellspacing="1" cellpadding="8" width="100%"> <tr><td><center><font color="#FF0000"><b>!!! Special lot, category is ${requestForm.lotCategory}, pls take care !!!</b></font></center></td></tr> </table> </#if> <hr/> <table width="100%"> <tr> <td class="center"> <!--input type="button" onclick="window.open('../stepForm/printRuncard.action?requestFormId=${requestForm.id}','','resizable=yes,scrollbars=yes,width=800,height=600')" value="Print"/-->     <input type="button" onclick="checkPageToPreview()" value="Preview"/> </td> </tr> </table> </form> </div>
最新发布
09-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值