究竟是什么process,并update在PrimeFaces p:commandXxx组件和execute和render的f:ajax标签?
哪个在验证时有效?什么是update属性做,而不是更新的值从后端组件?不要process属性绑定值模型?究竟是什么@this,@parent,@all并@form在这两个属性?
下面的例子工作正常,但我对基本概念有点困惑.
<p:commandButton process="@parent"
update="@form"
action="#{bean.submit}"
value="Submit" />
Run Code Online (Sandbox Code Playgroud) 我在JSF 2应用程序中使用Primefaces.我有一个<p:dataTable>,而不是选择行,我希望用户能够直接对各行执行各种操作.为此,我<p:commandLink>在最后一栏中有几个.
我的问题:如何将行ID传递给命令链接启动的操作,以便我知道要对哪一行进行操作?我尝试使用<f:attribute>:
<p:dataTable value="#{bean.items}" var="item">
...
<p:column>
<p:commandLink actionListener="#{bean.insert}" value="insert">
<f:attribute name="id" value="#{item.id}" />
</p:commandLink>
</p:column>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
但它总是产生0 - 显然在f呈现属性时行变量不可用(当我使用固定值时它可以工作).
有人有替代解决方案吗?
以下两段代码之间有什么区别 - 关于listener放置?
<h:selectOneMenu ...>
<f:selectItems ... />
<f:ajax listener="#{bean.listener}" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
和
<h:selectOneMenu ... valueChangeListener="#{bean.listener}">
<f:selectItems ... />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud) 我试图找到一个可以传递给f:ajax标签的属性"event"的所有可能值的列表.
我知道我也可以从我的.js文件中传递函数名称,但我需要的只是JSF附带的函数名称.
我只知道点击鼠标悬停和键盘,但我相信还有更多.只是不知道在哪里找到它们.
我需要在我的ajax请求中将参数传递给服务器.请参阅下面的代码.范围:查看范围
没有f:param
<p:column width="40">
<h:inputText id="originalCostInputTxt" value="#{articlePromo.costoBruto}"
<f:ajax event="change"
execute="@this"
listener="#{promotionDetailManagedBean.onCostoBrutoChange}">
</f:ajax>
</h:inputText>
</p:column>
Run Code Online (Sandbox Code Playgroud)
管理Bean
public final void onCostoBrutoChange(final AjaxBehaviorEvent event) {
createCostoBrutoOptions(promoArticlesList);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,会调用onCostoBrutoChange()方法.但是,当我包含f:param时,它不会被调用.请参阅下面的代码.
用f:param
<p:column width="40">
<h:inputText id="originalCostInputTxt" value="#{articlePromo.costoBruto}"
<f:ajax event="change"
execute="@this"
listener="#{promotionDetailManagedBean.onCostoBrutoChange}">
<f:param value="#{articlePromo.promocionArticuloId}" name="myId"/>
</f:ajax>
</h:inputText>
</p:column>
Run Code Online (Sandbox Code Playgroud)
管理Bean
public final void onCostoBrutoChange(final AjaxBehaviorEvent event) {
createCostoBrutoOptions(promoArticlesList);
String id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("myId");
}
Run Code Online (Sandbox Code Playgroud)
无法识别此代码中的错误.请指导.
谢谢,Shikha
我正在调用valueChangeListener一个<h:selectBooleanCheckbox>在dataTable中的内容.并且dataTable再次位于另一个(外部)dataTable中.在valueChangeListener方法中我想要外部dataTable的实例对象.有没有办法获取外部dataTable实例的对象?
EX:
<h:panelGroup id="panelId">
<p:dataTable id="outerDatatable"
var="supplier"
value="bean.supplierList">
<p:column>
<f:facet name="header">
<h:outputText value="Suppliers" />
</f:facet>
<h:outputText value="#{supplier.name}" />
</p:column>
<p:column>
<p:dataTable id="innerDataTable"
var="supplierAccount"
value="supplier.supplierAccountList">
<p:column>
<h:selectBooleanCheckbox id="booleanBoxId"
value="#{supplierAccount.supported}"
valueChangeListener="#bean.checkBoxListener}"
immediate="true"
onchange="this.form.submit();"/>
</p:column>
</p:dataTable>
</p:column>
</p:dataTable>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
我找到了以下解决方案:我使用了<p:ajax>listener而不是valueChangeListener,我可以将'supplier'对象以及supplierAccount对象传递给这个侦听器方法.我们可以将任意数量的自定义对象传递给<p:ajax>侦听器.
<p:column>
<h:selectBooleanCheckbox id="booleanBoxId"
value="#{supplierAccount.supported}"
immediate="true">
</h:selectBooleanCheckbox>
<p:ajax listener="#{bean.myListenerMethod(supplier,supplierAccount)}"
update=":formName:panelId"/>
</p:column>
Run Code Online (Sandbox Code Playgroud) jsf ×6
jsf-2 ×5
ajax ×3
primefaces ×2
commandlink ×1
datatable ×1
input ×1
listener ×1
process ×1
updates ×1