简体   繁体   English

p:selectOneMenu ajax无法在p:dataGrid中触发

[英]p:selectOneMenu ajax does not fire within p:dataGrid

I have a selectOneMenu rendered for each row of my dataGrid. 我为dataGrid的每一行呈现了一个selectOneMenu。 The problem is the method of the ajax listener is not called when the selection changes. 问题是选择更改时未调用ajax侦听器的方法。

If I use the same selectOneMenu outside the dataGrid, it works fine. 如果我在dataGrid外部使用相同的selectOneMenu,它将正常工作。 Same behaviour occurs with p:selectBooleanCheckbox. p:selectBooleanCheckbox会发生相同的行为。

XHTML page: XHTML页面:

<h:form id="form2">
  <p:dataGrid id="gridC" widgetVar="gridC" 
    value="#{myBean.comp}" var="site" columns="1" rowIndexVar="siteIndex">
    <p:column>
      <h:outputText value="#{site.sito}" />
    </p:column>
    <p:column>
      <p:selectOneMenu id="stato" value="#{site.stateId}" 
        required="true">
        <p:ajax update="@form :tabView:frm_buttons" global="false" 
          listener="#{myBean.testChangeState}" />
        <f:selectItems value="#{myBean.siteStates}" var="s"
          itemLabel="#{s.state}" itemValue="#{s.stateId}" />
      </p:selectOneMenu>
    </p:column>
  </p:dataGrid>
</h:form>

Managed bean: 托管豆:

@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
  private SiteState siteStates;
  private Comp comp;
  // getters and setters...

  public void testChangeState() {
    System.out.println("Test change state fired.");
  }
}

SiteState bean: SiteState bean:

public class SiteState implements Serializable {
  private String state;
  private String stateId;
  // getters and setters...
}

Found the secret. 找到了秘密。

The data grid is within a tab of an accordion panel, and I used an id like this: 数据网格位于“手风琴”面板的选项卡中,我使用了这样的ID:

<p:tab id="sito#{sito.idSitoStoccaggio}"

This is not the case, because it produces strange behaviours in some situations, like events not firing from within a data grid, for example. 事实并非如此,因为在某些情况下它会产生奇怪的行为,例如事件不是从数据网格内触发的。

Switching to: 切换至:

<p:tab id="sito"

resolved my issue. 解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM