将参数传递给 PrimeFaces Star Rating 组件? [英] Passing parameters to PrimeFaces Star Rating component?
问题描述
我正在尝试使用 PrimeFaces 的 Star Rating 组件.但是,它不允许您传入参数.这使我无法进行查找以从数据库中获取我想要评分的实体.我试过这样的事情,但没有成功:
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 Star Rating 组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!