我可以跳过生成html并在JSF呈现响应阶段更新组件吗?
例如,我有一个我可以跳过生成html并在JSF呈现响应阶段更新组件吗?,jsf,Jsf,例如,我有一个命令按钮,如下所示: <p:commandButton actionListener="#{logicBean.doSomething}" update="component1 component2 component3" /> 那么,是否可以从logicBean.doSomething方法中跳过重新生成和呈现component3?这意味着在返回的响应中,component3没有新的HTML 我已经尝试了Fa
命令按钮
,如下所示:
<p:commandButton
actionListener="#{logicBean.doSomething}"
update="component1 component2 component3"
/>
那么,是否可以从logicBean.doSomething
方法中跳过重新生成和呈现component3
?这意味着在返回的响应中,component3
没有新的HTML
我已经尝试了
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().remove(“组件3”)代码>但它不起作用。您可以在bean之外执行更新:
public void doSomething() {
/* do the stuff */
if(haveToDo)
PrimeFaces.current().ajax().update( "component3" )
// with older primefaces
// RequestContext.getCurrentInstance().update( "component3" );
}
但是您必须查找完整的id。它可能是“tab2:myform:component3”您可以在bean之外执行更新:
public void doSomething() {
/* do the stuff */
if(haveToDo)
PrimeFaces.current().ajax().update( "component3" )
// with older primefaces
// RequestContext.getCurrentInstance().update( "component3" );
}
但是您必须查找完整的id。它可能是“tab2:myform:component3”FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds()的实际内容是什么?它确实包含一个与“component3”
完全匹配的字符串吗?嗨@BalusC,是的,它将返回一个包含“component3”的列表。FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds()的实际内容是什么?它确实包含一个与“component3”
完全匹配的字符串吗?您好@BalusC,是的,它将返回一个包含“component3”的列表。谢谢您的回答,但这里似乎有一个误解。我想从呈现响应阶段删除“component3”。是的,不要在html中编写它,而是随时从bean中添加它。感谢您的回答,但这里似乎存在误解。我想从呈现响应阶段删除“component3”。是的,不要在html中编写它,而是随时从bean中添加它。