首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Primefaces更新

Primefaces更新
EN

Stack Overflow用户
提问于 2014-01-31 22:37:26
回答 3查看 451关注 0票数 1

你好,我有一些更新的问题,我有一些复合组件嵌套在几个组件中,我想要更新其中的一些,什么是正确的方式?第二,我可以更新div吗?

代码示例:

代码语言:javascript
复制
<div id="outer">
    <p:commandButton id="button"/>
    <div id="inner">
        <h:form id="form">
             <mycomponents:test whatToUpdate="form panel button outer label">//here problem
        </h:form>
    </div>
</div>
<div id="outer2">
     <h:form id="form">
         <p:panelGroup id="panel">
             <p:label id="label" value="value"/>
         </p:panelGroup>
    </h:form>
</div>
EN

回答 3

Stack Overflow用户

发布于 2014-01-31 22:42:15

使用p:outputPanel代替div

代码语言:javascript
复制
<p:outputPanel id="outer">
    <p:commandButton id="button" update="inner"/>
    <p:outputPanel id="inner">
        <h:form id="form">
             <mycomponents:test whatToUpdate="form panel button outer label">//here problem
        </h:form>
    </p:outputPanel>
</p:outputPanel>
票数 0
EN

Stack Overflow用户

发布于 2014-04-07 21:46:54

我找到了一些更新嵌套组件的简单方法(我想是的),我希望有人会发现这很有用。这个想法是将styleClass设置为primefaces组件(不知道一些随机的styleClass名称),并使用该styleClass更新组件。例如:

代码语言:javascript
复制
...bla bla nested components
<p:panel id="somePanel" styleClass="somePanelStyle">
`... bla bla nested components`
<p:panel>
... bla bla nested components

any如果您需要通过按钮更新它(在此示例面板中,其id为"somePanel"),例如:

代码语言:javascript
复制
<p:commanButton update="@(.somePanelStyle)"

目前,我只是使用这种方式,因为它很容易实现更新和搜索(eclipse中的CTRL+H),其中是该组件。

关于更新div,BalusC得到了一些很好的答案:Answer about updating divs from JSF by BalusC

票数 0
EN

Stack Overflow用户

发布于 2014-12-14 20:13:58

在给出我的答案之前,我想做一些假设:

首先,你对两个h:form使用相同的标识符,这是一个错误,,

  • ,我不知道是什么确切地代表了你的组合中的whatToUpdate,但我猜它绑定到了某个update属性上。

  • 我认为复合组件whatToUpdate属性中的form值引用了外部的div。

  • JSF上下文中我不建议您使用div,我只会将它们放在HTML模板代码的位置。在D17上下文中,我不建议您更新D18组件外部的元素,特别是如果您的D19是提交按钮。H220H121我注意到您只希望将组件更新到两个子树中,如果您将所有内容都放在一个h:form中,那么只需使用表单referencing.

就可以更容易地更新子树中的每个组件

这是我的这是我会在你的位置上做的事情:

代码语言:javascript
复制
<h:form id="form1">
  <p:outputPanel id="outer">
    <p:commandButton id="button"/>
    <p:outputPanel id="inner">
         <mycomponents:test whatToUpdate="@form :form2">
    </p:outputPanel>
  </p:outputPanel>
</h:form>

<h:form id="form2">
  <p:outputPanel id="outer2">
     <p:panelGroup id="panel">
         <p:label id="label" value="value"/>
     </p:panelGroup>
  </p:outputPanel>
</h:form>

这样,您将以最简单的方式更新form1form2的每个组件,并且不必再担心是否要在其中一个子树中添加一些组件。

如果我的假设有误,请告诉我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21482621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档