在JSF/Primefaces页面中,我有一个包含表视图的表单,其中每个选项卡包含一个手风琴面板,每个手风琴面板包含一个数据表。单个数据表的完整id类似于id="form:tabs:0:accordion:0:table"
每个选项卡还包含一个命令按钮,该按钮必须更新选项卡本身的数据表,因此它不会更新其他选项卡中的表。
使用Primefaces选择器,我设法更新了id以"table"结束的所有数据表:update="searchValue @('div$=table')
,但我无法处理id以"0:table"结束的所有数据表,其中"0"是动态的(基于当前选项卡)。
I tried with:
<ui:param name="ta" value="#{settore.id - 1}:table" />
<p:commandButton id="plainSearch" value="Filter"
action="#{myBean.search()}"
update="@('div$=#{ta}')">
,但它给了我一个Javascript错误:Uncaught Syntax Error: Unexpected identifier
,然后整个表单更新。
如何将变量正确地传递给Primefaces选择器?
这是我的XHTML页面:
<h:form id="form">
<p:tabView id="tabs" value="#{myBean.sectors}" var="tab">
<p:tab id="tab" title="#{tab.description}">
<p:commandButton id="plainSearch" value="Filter"
action="#{myBean.search()}"
update="@('div$=table')">
<p:accordionPanel id="accordion" value="#{myBean.getTabs()}" var="tab" multiple="true" activeIndex="#{myBean.activeIndexes}">
<p:tab id="accordionTab" title="#{tab.title}">
<p:dataTable id="table" var="row" value="#{myBean.getObjects()}" emptyMessage="Empty table">
<p:column headerText="Code">
<h:outputText value="#{row.codice}" />
</p:column>
<p:column headerText="Description">
<h:outputText value="#{row.descrizione}" />
</p:column>
</p:dataTable>
</p:tab>
</p:accordionPanel>
</p:tab>
</p:tabView>
</h:form>
我对(jquery)选择器本身有点困惑。如果我理解正确的话,primefaces现在正在使用jquery选择器,@()的语法将把它识别为jquery选择器。
如果它是一个jquery选择器(属性以选择器结束)不应该是这样的:
$(div[id$=table])
和id为
的版本$(div[id$=#{ta}\:table])
编辑:我已经更新了代码示例(不带引号)