简体   繁体   English

Param值没有首次使用commandLink标记 - JSF 1.X传递给控制器

[英]Param value is not being passed to the controller for the first time using commandLink tag - JSF 1.X

I am passing a value to the controller class through commandLink tag(below is the code). 我通过commandLink标记将值传递给控制器​​类(下面是代码)。 First of all I am retrieving few records as tabledata and then while click on the ID, it will navigate to another page to show the details. 首先,我正在检索少量记录作为tabledata,然后在单击ID时,它将导航到另一个页面以显示详细信息。 But in this case the parameter value is not being passed to the controller for the very first time. 但在这种情况下,参数值第一次没有传递给控制器​​。 In the controller I am getting null due to which it fails to load the data. 在控制器中,我因为无法加载数据而变为null。

I've gone through a link which says it is a bug in the JSF 1.X (see the point-10 in below link). 我已经通过一个链接说明它是JSF 1.X中的一个错误(参见下面链接中的第10点)。 i need to fix this with commandLink tag only. 我只需要使用commandLink标签解决这个问题。

The code works fine in another functionality using the same commandLink tag but i do not understand why is it not working in this scenario. 代码在使用相同commandLink标记的另一个功能中工作正常,但我不明白为什么它在这种情况下不起作用。 Below are the not working and working code. 以下是无法正常工作的代码。

Not working: 不工作:

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

Working: 工作:

</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..
}}

Link for previous discussion. 以前讨论的链接。 commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated commandButton / commandLink / ajax动作/侦听器方法未调用或输入值未设置/更新

This issue is resolved by adding another parameter of the same attribute in the JSP and working with that parameter in the controller, but still I don't understand the logic behind this. 通过在JSP中添加相同属性的另一个参数并在控制器中使用该参数来解决此问题,但我仍然不理解这背后的逻辑。 Appreciate if anyone can explain. 感谢是否有人可以解释。

<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>

Controller: 控制器:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM