Forums Register Login

h:commandLink and page Navigation

+Pie Number of slices to send: Send
I am displaying a list with <h atatable>.

The First column has MerchantName.

The merchantName when displayed is a link to MerchantDetails screen.

<h:column>
<f:facet name="header">
<h utputText styleClass="ListHead" value="#{msgs.name}"
id="text1">
</h utputText>
</f:facet>
<h:commandLink styleClass="commandLink" id="link1">
<h utputText value="#{results.merchantName}"></h utputText>
</h:commandLink>

How do I display the merchantName but when clicked pass the merchantNumber to the MerchantDetails page?

I do not see any option to do that using commandlink.

Do I have to stick to <a:href> tag instead???

Any thoughts
+Pie Number of slices to send: Send
Sorry there was a Typo in the query below.

I wanted to ask

" How do I pass the merchantNumber when the Merchantname link is clicked"?
+Pie Number of slices to send: Send
I found a solution.

For anybody else who might be having a similar problem use the <f aram> tag to pass parameters.

<h:column>
<f:facet name="header">
<h utputText styleClass="ListHead" value="#{msgs.name}" id="text1"></h utputText>
</f:facet>
<h:commandLink styleClass="commandLink" id="link1" action="#{pc_MerchantSearchResults.followLink}">
<h utputText value="#{results.merchantName}"></h utputText>
<f aram name="merchantNumber" value="12345678"></f aram>
</h:commandLink>
</h:column>

And in the method you can access the parameters as below

public void followLink(){
String columnValue = (String)FacesContext.getCurrentInstance).getExternalContext().getRequestParameterMap().get("merchantNumber");
System.out.println("columnValue = " + columnValue);
}

Hope this helps.
+Pie Number of slices to send: Send
instead of the method to access passed parameter through command link

use #{para.FileNumber}

it is better than using following code

And in the method you can access the parameters as below

public void followLink(){
String columnValue = (String)FacesContext.getCurrentInstance).getExternalContext().getRequestParameterMap().get("merchantNumber");
System.out.println("columnValue = " + columnValue);
}
+Pie Number of slices to send: Send
instead of the method to access passed parameter through command link

use #{param.PARAMATER_NAME}
where param is request level object and it is in built in jsf
it is better than using following code


public void followLink(){
String columnValue = (String)FacesContext.getCurrentInstance).getExternalContext().getRequestParameterMap().get("merchantNumber");
System.out.println("columnValue = " + columnValue);
}


Thanks

Gaurav
+Pie Number of slices to send: Send
Gaurav

Where do u specify the param.PARAMETER_VALUE in jsp ??

Can you use my sample code above and modify it to make understanding better..
I didn't say it. I'm just telling you what this tiny ad said.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1964 times.
Similar Threads
logic:iterate functionality with jsf
Model update problem
how to use TreeSelectionListener in a tree ?
Problem with h:dataTable
Links in dynamic form
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:52:34.