我想remoteCommand从javascript 传递价值.如果可以的话,我怎么能这样做,如何在支持bean中接收它们?
给定以下XHTML代码,其中包含一个<p:inputText>且<p:dataTable>只有两列.
<p:remoteCommand name="updateTable" update="dataTable"/>
<p:panel id="panel">
<p:inputText id="txtValue" value="#{testManagedBean.txtValue}"
required="true"/>
<p:message for="txtValue" showSummary="false"/>
<p:commandButton actionListener="#{testManagedBean.submitAction}"
oncomplete="if(!args.validationFailed) {updateTable();}"
update="panel" value="Submit"/>
</p:panel>
<p:panel id="dataTablePanel" header="Data">
<p:dataTable id="dataTable" var="row" value="#{testManagedBean}"
lazy="true"
pageLinks="10"
editable="true"
rowsPerPageTemplate="5,10,15"
rows="10"
rowKey="#{row.catId}"
editMode="row">
<p:ajax event="rowEdit" update=":form:panel dataTable"
listener="#{testManagedBean.onRowEdit}"/>
<p:column id="id" headerText="Id">
<h:outputText value="#{row.catId}"/>
</p:column>
<p:column id="catName" headerText="Category">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{row.catName}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{row.catName}" label="Category">
<f:validateLength minimum="2" maximum="45"/>
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit" width="100">
<p:rowEditor/>
</p:column>
</p:dataTable>
</p:panel>
Run Code Online (Sandbox Code Playgroud)
<p:commandButton>按下给定时,将submitAction() …
Primefaces 3.5 JSF 2.1
\n\nI\xc2\xb4m 使用 p:remoteCommand 执行异步命令并在页面加载后更新我的视图,但看起来在每次迭代结束时它会再次执行等等...
\n\n这种行为正确吗?
\n\n如何只执行一次p:remoteCommand?
\n\n更新
\n\n我已经检查过我的远程命令不在更新面板中,所以感谢您的回答,但已经可以了。我如何解决我的问题:
\n\n我不知道为什么,但使用 Omnifaces 的 onloadScript ( http://showcase.omnifaces.org/components/onloadScript ) 来调用它被调用多次的 RemoteCommand 函数,但使用 $(document).ready ...仅一次。所以,我改变了它,现在就可以使用了。
\n