ui 内的复选框:Ajax 未刷新重复

发布于 2024-12-15 03:28:39 字数 2190 浏览 5 评论 0原文

我使用 Mojarra 2.1.3。

当用户单击“刷新不起作用”按钮时,它会刷新 ui:repeat 的内容。我希望选中该复选框,就像初始化时一样。

我发现了什么:如果我删除 Facelet 中的 h:head “刷新不起作用”有效...有什么想法吗?

Facelet:

<h:head></h:head>
<h:body>
<h:form id="myForm" >
<h:panelGroup id="panelToRefreshOutsideRepeat">
  <ui:repeat value="#{sandbox.columns}" var="column">
     <h:panelGroup id="panelToRefreshInsideRepeat">
     <h2>composite onlyCheckbox:</h2>
     <trc:onlyCheckbox value="#{column.value}" />
     <br />
     <h2>composite onlyInputText:</h2>
     <trc:onlyInputText value="#{column.value}" />
     <br />
     <br/>
     <h:commandButton  value="Refresh don't work" >
        <f:ajax render="panelToRefreshInsideRepeat" />
     </h:commandButton>
     <h:commandButton  value="Refresh work" >
        <f:ajax render=":myForm:panelToRefreshOutsideRepeat" />
     </h:commandButton>
     </h:panelGroup>
     <br/> 
  </ui:repeat>
</h:panelGroup>

onlyCheckbox 和 onlyInputText 的组合:

<composite:interface>
<composite:attribute name="value" 
                     type="boolean"/> 
</composite:interface>
<composite:implementation>
boolean: <h:selectBooleanCheckbox value="#{cc.attrs.value}" />
<!-- for onlyInputText h:inputText instead of h:selectBooleanCheckbox -->
boolean value: #{cc.attrs.value}
</composite:implementation>

以及支持 bean:

@ManagedBean
@RequestScoped
public class Sandbox {
    public List<Column> columns = Arrays.asList(new Column(true));

    public List<Column> getColumns() {
      return columns;
    }        
    public void setColumns(List<Column> columns) {
    this.columns = columns;
    }

    public class Column {
       private boolean value;
       public Column(boolean value) {
          this.value = value;
       }
       public void setValue(boolean value) {
          this.value = value;
       }
       public boolean getValue() {
          return this.value;
       }
    }
}

I work with Mojarra 2.1.3.

When the user click on button "refresh don't work", it refresh the content of the ui:repeat.I expect the checkbox to be checked, just as at the initialization.

What I've found: If I remove h:head in the facelet "refresh don't work" works... Any idea ?

The facelet:

<h:head></h:head>
<h:body>
<h:form id="myForm" >
<h:panelGroup id="panelToRefreshOutsideRepeat">
  <ui:repeat value="#{sandbox.columns}" var="column">
     <h:panelGroup id="panelToRefreshInsideRepeat">
     <h2>composite onlyCheckbox:</h2>
     <trc:onlyCheckbox value="#{column.value}" />
     <br />
     <h2>composite onlyInputText:</h2>
     <trc:onlyInputText value="#{column.value}" />
     <br />
     <br/>
     <h:commandButton  value="Refresh don't work" >
        <f:ajax render="panelToRefreshInsideRepeat" />
     </h:commandButton>
     <h:commandButton  value="Refresh work" >
        <f:ajax render=":myForm:panelToRefreshOutsideRepeat" />
     </h:commandButton>
     </h:panelGroup>
     <br/> 
  </ui:repeat>
</h:panelGroup>

The composite for onlyCheckbox and onlyInputText:

<composite:interface>
<composite:attribute name="value" 
                     type="boolean"/> 
</composite:interface>
<composite:implementation>
boolean: <h:selectBooleanCheckbox value="#{cc.attrs.value}" />
<!-- for onlyInputText h:inputText instead of h:selectBooleanCheckbox -->
boolean value: #{cc.attrs.value}
</composite:implementation>

and the backing bean:

@ManagedBean
@RequestScoped
public class Sandbox {
    public List<Column> columns = Arrays.asList(new Column(true));

    public List<Column> getColumns() {
      return columns;
    }        
    public void setColumns(List<Column> columns) {
    this.columns = columns;
    }

    public class Column {
       private boolean value;
       public Column(boolean value) {
          this.value = value;
       }
       public void setValue(boolean value) {
          this.value = value;
       }
       public boolean getValue() {
          return this.value;
       }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

氛圍 2024-12-22 03:28:39

即使在最新的 Mojarra 2.1.4 上我也可以重现您的问题。如果复选框不在组合内部,则效果很好。这是 Mojarra 的 中的一个错误。是总计莫哈拉 (Mojarra) 损坏。它在 MyFaces 2.1.3 上运行得非常好。

您有 2 个选择:

  • 用 MyFaces 替换 Mojarra。
  • 使用 UIData 组件代替 ,例如 ;

I can reproduce your problem even on latest Mojarra 2.1.4. It works fine if the checkbox is not inside a composite. This is a bug in Mojarra's <ui:repeat>. It is totally broken in Mojarra. It works perfectly fine on MyFaces 2.1.3.

You have 2 options:

  • Replace Mojarra by MyFaces.
  • Use an UIData component instead of <ui:repeat>, e.g. <h:dataTable>, <t:dataList>, <p:dataList>, etc.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文