[英]Param value is not being passed to the controller for the first time using commandLink tag - JSF 1.X
我通过commandLink标记将值传递给控制器类(下面是代码)。 首先,我正在检索少量记录作为tabledata,然后在单击ID时,它将导航到另一个页面以显示详细信息。 但在这种情况下,参数值第一次没有传递给控制器。 在控制器中,我因为无法加载数据而变为null。
我已经通过一个链接说明它是JSF 1.X中的一个错误(参见下面链接中的第10点)。 我只需要使用commandLink标签解决这个问题。
代码在使用相同commandLink标记的另一个功能中工作正常,但我不明白为什么它在这种情况下不起作用。 以下是无法正常工作的代码。
不工作:
JSP:
<hx:columnEx id = "columnRequestID">
<f:facet name = "header">
<hx:sortHeader styleClass = "sortHeader" id = "sortRequestID"
defaultSortOrder = "sortbi">
<h:outputText id = "outputTxtRequestID" styleClass = "outputText sortOverlap"
value = "#{pc_Controller.propertiesMap.txtRequestID}"/> </hx:sortHeader> </f:facet>
<h:commandLink styleClass = "outputLinkEx" id = "lnKrequestID"
value = "#{searchResult.requestID}" actionListener = "#{pc_Controller.handleActionEvent}"
action = "#{pc_Controller.processRCAction}">
<f:param value = "#{searchResult.requestID}"
name = "paramRequestID"/>
</h:commandLink> </hx:columnEx>
Controller:
if("lnKrequestID".equals(action)){
if (request.getParameter("paramSCRequestID") != null) { // This is not
really null but but an empty value
String reqID = request.getParameter("paramSCRequestID"); // Here no value
工作:
</f:facet>
<h:commandLink styleClass = "outputLinkEx" id = "lnKrequestID"
value = "#{reportResult.requestID}"
action = "#{pc_Controller.processRCAction}" actionListener = "#{pc_Controller.handleActionEvent}">
<f:param value = "#{reportResult.requestID}"
name = "paramRequestID"/>
<f:param value = "#{reportResult.requestType}"
name = "paramRequestType"/>
</h:commandLink>
Controller:
if("lnKrequestID".equals(action)){
if(request.getParameter("paramSetStatusRequestType")!= null ){
String requestId=request.getParameter("paramRequestID"); // Here i am
getting value at all time
//Some code..
}}
以前讨论的链接。 commandButton / commandLink / ajax动作/侦听器方法未调用或输入值未设置/更新
通过在JSP中添加相同属性的另一个参数并在控制器中使用该参数来解决此问题,但我仍然不理解这背后的逻辑。 感谢是否有人可以解释。
<h:commandLink styleClass = "outputLinkEx" id = "lnKrequestID"
value = "#{searchResult.requestID}"
actionListener = "#{pc_Controller.handleActionEvent}"
action = "#{pc_Controller.processRCAction}">
<f:param value = "#{searchResult.requestID}"
name = "paramRequestID"/>
<f:param value = "#{searchResult.requestID}"
name = "paramRequestIDSec"/>
</h:commandLink>
控制器:
if("lnKrequestID".equals(action)){
if (request.getParameter("paramSCRequestIDSec") != null) {
String reqID = request.getParameter("paramSCRequestID"); // Here it is null
String reqIDSec = request.getParameter("paramSCRequestIDSec"); // Here value is being passed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.