aspose file tools*
The moose likes JSF and the fly likes h:commandLink and page Navigation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:commandLink and page Navigation" Watch "h:commandLink and page Navigation" New topic
Author

h:commandLink and page Navigation

allen gilbert
Greenhorn

Joined: May 31, 2006
Posts: 13
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

Joined: May 31, 2006
Posts: 13
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

Joined: May 31, 2006
Posts: 13
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

Joined: Jul 19, 2005
Posts: 64
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 S.
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
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

Joined: May 31, 2006
Posts: 13
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..
 
Consider Paul's rocket mass heater.
 
subject: h:commandLink and page Navigation