ui:repeat内的复选框未由Ajax刷新 [英] Checkbox inside ui:repeat not refreshed by Ajax

查看:141
本文介绍了ui:repeat内的复选框未由Ajax刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Mojarra 2.1.3.

I work with Mojarra 2.1.3.

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

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.

我发现的结果:如果我删除了小面中的h:head,则刷新不起作用"有效...知道吗?

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

方面:

<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的组合:

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>

和辅助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;
       }
    }
}

推荐答案

即使在最新的Mojarra 2.1.4上,我也可以重现您的问题.如果该复选框不在复合材料内部,则效果很好.这是Mojarra的<ui:repeat>中的错误.它是 MyFaces 2.1.3 上可以正常工作.

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.

您有2个选择:

  • 用MyFaces代替Mojarra.
  • 使用UIData组件代替<ui:repeat>,例如<h:dataTable><t:dataList><p:dataList>
  • Replace Mojarra by MyFaces.
  • Use an UIData component instead of <ui:repeat>, e.g. <h:dataTable>, <t:dataList>, <p:dataList>, etc.

这篇关于ui:repeat内的复选框未由Ajax刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆