• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

h:commandLink and page Navigation

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic