英文:
Pass parameter from Primefaces sheet to backing bean
问题
你想从PrimeFaces表格列传递参数到JSF后端bean,如下所示:
<pe:sheetcolumn headerText="HTS Chapter" value="#{material.htsChapter}" colWidth="100"
rendered="true"
colType="dropdown"
readonlyCell="#{!itemActionsManagedBean.authCheckForEditForHtsChapter(material.country)}"
selectItems="#{itemActionsManagedBean.getMapItemsForHtsChapter(material.country)}"/>
我可以通过readonlyCell
属性传递参数。但是对于selectItems
,它无法将参数传递到后端bean。它总是传递null
给selectItems
。我的范围是@ViewScoped
。
JSF版本:2.2.1,PrimeFaces版本:12.0.0,PrimeFaces扩展版本:12.0.5。
英文:
I want to pass parameters from primefaces sheet column to jsf backing bean like below.
<pe:sheetcolumn headerText="HTS Chapter" value="#{material.htsChapter}" colWidth="100"
rendered="true"
colType="dropdown"
readonlyCell="#{!itemActionsManagedBean.authCheckForEditForHtsChapter(material.country)}"
selectItems="#{itemActionsManagedBean.getMapItemsForHtsChapter(material.country)}"/>
I can pass parameters via readonlyCell attribute. But with selecitems it doesnt pass parameters to backing bean. Its always passing null for selectitems. My scope is @ViewScoped.
JSF: 2.2.1, PrimeFaces: 12.0.0, PrimeFaces Extensions: 12.0.5
答案1
得分: 1
SelectItems 不是每一行调用一次,而是对整个列调用一次,ReadOnly 则是每行评估一次,这是它们之间的区别。SelectItems 不能在每一行中有不同的值,这也是为什么它只被调用一次以提高性能的原因,因此在调用时会期望 NULL,因为你并不处于行的“上下文”中。因此,当调用 SelectItems 时,material.country
是 NULL,因为 material
是你的行,甚至还没有被评估。
英文:
SelectItems is NOT called per row its called once for the whole column and ReadOnly is evaluated per row that is the difference. SelectItems cannot be different per row which for performance is why its called only once so NULL is expected as you are not in "context" of a row. So material.country
is NULL when SelectItems is called because material
is your ROW which is not even evaluated yet.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论