0

I am passing a value to the controller class through commandLink tag(below is the code). 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. 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.

I've gone through a link which says it is a bug in the JSF 1.X (see the point-10 in below link). i need to fix this with commandLink tag only.

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

Mr. SKS
  • 1
  • 1

1 Answers1

0

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. 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
Mr. SKS
  • 1
  • 1