Hi I have a code like:
<p:commandLink value="#{user.strUserid}" action="test.xhtml?faces-redirect=true"/>
How can I pass a parameter to test.xhtml to get the value in the said page?
I tried with <f:param>
tag.But can get the value in the test.xhtml
page.
Please suggest.
Replace it by <h:link>
<h:link value="#{user.strUserid}" outcome="test.xhtml">
<f:param name="foo" value="bar" />
</h:link>
and use <f:viewParam>
to set it as a property of the bean associated with target page
<f:metadata>
<f:viewParam name="foo" value="#{bean.foo}" />
</f:metadata>
Then I think you need to try <f:setPropertyActionListener ..
<h:commandButton action="#{testBean.takeParam}" >
<f:setPropertyActionListener target="#{testBean.myStringVal}" value="something" />
</h:commandButton>
And then You can get this value in your bean class
@SessionScoped
public class TestBean{
public String myStringVal;
public void setMyStringVal(String myStringVal) {
this.myStringVal = myStringVal;
}
}
public void takeParam{
System.out.println("String Value: "+myStringVal);
}
Also see Communication in JSF by BalusC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With