Richfaces extendedDataTable在另一个extendedDataTable中

时间:2013-08-21 15:47:48

标签: java jsf richfaces richdatatable

所以我有一个extendedDataTables如下(缩短代码以保持简单)。

    <rich:extendedDataTable value="#{package.packageList}" var="o"
                styleClass="listStyle" selection="#{package.selection}"
                selectionMode="single">

                <a4j:ajax execute="@form" event="selectionchange"
                    listener="#{package.selectionListener}" render=":res" />
                <rich:column>

                    <f:facet name="header">Package ID</f:facet>
                    #{o.packageID}

                </rich:column>
    </rich:extendedDataTable>

因此,当用户点击它时,它会将其详细信息输出到随后的a4j:outputPanel内的另一个表中。

     <a4j:outputPanel id="res">
            <rich:panel header="Selected Package"
                rendered="#{not empty package.selectionPackage}">
                </rich:panel>
      </a4j:outputPanel>

这部分有效。但是,这个新细节现在包含几个变量以及我需要也能够选择的对象的arrayList。所以这个arrayList生成自己的extendedDataTable,然后我需要选择并检索它的信息。这部分是破碎的地方。到目前为止我所尝试的内容如下:

   <a4j:outputPanel id="res">
            <rich:panel header="Selected Package"
         rendered="#{not empty package.selectionPackage}">
                 <rich:dataTable value="#{package.selectionPackage}"
                    var="extensionTable" styleClass="listStyle" selectionMode="single">
                    <rich:column>
                        <rich:extendedDataTable value="#                                         {extensionTable.extensionList}"
                            var="selectedExtension" styleClass="listStyle" style="height:200px;"
                            selection="#{package.extensionSelection}" selectionMode="single">

                            <a4j:ajax execute="@form" event="selectionchange"
                    listener="#{package.selectionExtensionListener}" render=":extensions" />
                            <rich:column>
                                <f:facet name="header">Extension Add on list</f:facet>
                                #{selectedExtension.extensionName}"
                            </rich:column>
                        </rich:extendedDataTable>
                    </rich:column>
                </rich:dataTable>
                                   </rich:panel>
        </a4j:outputPanel>

我有另一个a4j面板来处理新的扩展选择对象。问题是我的selectedExtensionListener没有被调用。我不知道为什么,我正在尝试甚至可能。选择正在行,因为行正在改变颜色,但是从不调用selectionExtensionListener。我有一些system.out.printlnts只是为了检查,而第一个监听器被调用,第二个监听器不是。请原谅我,如果这是显而易见的甚至是不可能的,但我对jsf相对较新。任何帮助将不胜感激。

我将在下面复制并粘贴我的bean,以显示代码的后端。我将排除声明我的所有变量并填充我的列表和对象等,因为它只会堵塞代码,如果你需要它们只是让我知道,我会编辑它们。(抱歉格式化,我不知道你是否可以在这里格式化代码吗?)

   public class Package implements Serializable{
        public void selectionListener(AjaxBehaviorEvent event) {
    System.out.println("In selection listener");
           UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();
           Object originalKey = dataTable.getRowKey();
           selectionPackage.clear();
           for (Object selectionKey : selection) {
             dataTable.setRowKey(selectionKey);
             if (dataTable.isRowAvailable()) {
                selectionPackage.add((PackageClass) dataTable.getRowData());
            }
      }
    dataTable.setRowKey(originalKey);
}
public void selectionExtensionListener(AjaxBehaviorEvent event) {
    System.out.println("Testing 1");
    UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();
    Object originalKey = dataTable.getRowKey();
    selectionExtension.clear();
    for (Object selectionKey : extensionSelection) {
        dataTable.setRowKey(selectionKey);
        if (dataTable.isRowAvailable()) {
            System.out.println("Testing 2");
            selectionExtension.add((ExtensionClass) dataTable.getRowData());
        }
    }
    dataTable.setRowKey(originalKey);
}
 public Collection<Object> getSelection() {
    return selection;
}

public void setSelection(Collection<Object> selection) {
    this.selection = selection;
}
public Collection<Object> getExtensionSelection() {
    return extensionSelection;
}

public void setExtensionSelection(Collection<Object> extensionSelection) {
    this.extensionSelection = extensionSelection;
}


public List<PackageClass> getPackageList() {
    return packageList;
}
 public void setPackageList(ArrayList<PackageClass> packageList) {
        this.packageList = packageList;
}
 public PackageClass getSelectionPackage() {
    if (selectionPackage == null || selectionPackage.isEmpty()) {
        return null;
    }
    return selectionPackage.get(0);
}
 public void setSelectionPackage(ArrayList<PackageClass> selectionPackage) {
        this.selectionPackage = selectionPackage;
}
 public ArrayList<PackageClass> getSelectionPackages() {
    return selectionPackage;
}
 public ExtensionClass getSelectionExtension() {
    if (selectionExtension == null || selectionExtension.isEmpty()) {
        return null;
    }
    return selectionExtension.get(0);
}
 public void setSelectionExtension(ArrayList<ExtensionClass> selectionExtension) {
        this.selectionExtension = selectionExtension;
}
 public ArrayList<ExtensionClass> getSelectionExtensions() {
    return selectionExtension;
}
     }

0 个答案:

没有答案