Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

h:commandLink and page Navigation

 
allen gilbert
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
allen gilbert
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?
 
allen gilbert
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manish Sridharan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}
 
Manish Sridharan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
allen gilbert
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic