嗨,我有一个类似这样的代码:
<p:commandLink value="#{user.strUserid}" action="test.xhtml?faces-redirect=true"/>如何将参数传递给test.xhtml以获取上述页面中的值?我尝试使用<f:param> tag.But可以在test.xhtml页面中获取值。请提个建议。
发布于 2013-06-25 19:46:05
用<h:link>替换它
<h:link value="#{user.strUserid}" outcome="test.xhtml">
<f:param name="foo" value="bar" />
</h:link>并使用<f:viewParam>将其设置为与目标页关联的bean的属性
<f:metadata>
<f:viewParam name="foo" value="#{bean.foo}" />
</f:metadata>另请参阅:
发布于 2013-06-25 16:35:23
那我觉得你应该试试<f:setPropertyActionListener ..
<h:commandButton action="#{testBean.takeParam}" >
<f:setPropertyActionListener target="#{testBean.myStringVal}" value="something" />
</h:commandButton>然后,您可以在bean类中获取此值
@SessionScoped
public class TestBean{
public String myStringVal;
public void setMyStringVal(String myStringVal) {
this.myStringVal = myStringVal;
}
}
public void takeParam{
System.out.println("String Value: "+myStringVal);
}另请参阅Communication in JSF by BalusC
https://stackoverflow.com/questions/17292442
复制相似问题