将参数传递给PrimeFaces星级组件? [英] Passing parameters to PrimeFaces Star Rating component?
问题描述
我正在尝试使用PrimeFaces的星级组件。但是,它不允许您传入参数。这使得我无法进行查找以从数据库中获取我想要评分的实体。我尝试过这样的事情,但没有成功:
I'm trying to make use of the Star Rating component from PrimeFaces. However, it does not allow you to pass in parameters. That makes it impossible for me to do a lookup to get the entity from the database that I'd like to rate. I've tried something like this, but with no success:
<p:rating value="#{myAction.rating}">
<f:param name="myObjID" value="#{myObj.id}" />
</p:rating>
还有另一种方法可以将参数传递给我的动作类吗?有什么我想念的东西会让我得到我想要的行为吗?谢谢你的帮助!
Is there another way that I can pass the parameter into my action class? Is there something I'm missing that would allow me to get the behavior I want? Thanks for your help!
推荐答案
我终于想出了如何做到这一点......
I finally figured out how to do this...
<h:form>
<p:rating value="#{myAction.rating}" />
<input type="hidden" name="selectedObj" value="#{myObj.id}" />
</h:form>
然后,在我的动作类中,我可以通过执行此操作获取selectedObj的值。 ..
Then, in my action class, I'm able to get the value for selectedObj by doing this...
String selectedObjID = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("selectedObj");
一块蛋糕!
这篇关于将参数传递给PrimeFaces星级组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!