p:treeTable 中 CommandLink/CommandButton 的操作未调用

发布于 2024-12-29 22:04:06 字数 3355 浏览 0 评论 0原文

我下载 primefaces 3.1,添加到我的项目中尝试将 commandButton/commandLink 添加到 treeTable 的列中 但除根行外,不会调用列中的 commandButton/commandLink 的操作。

可能是什么问题?谢谢

编辑:

xhtml 中的treeTable:

<p:treeTable var="catalog" value="#{catalogSelectBean.root}" lazy="true" selection="#{catalogSelectBean.selectedNode}" selectionMode="single">
    <p:column>
        <f:facet name="header">
        <h:outputText value="Katalog Name" />
        </f:facet>
        <h:outputText value="#{catalog.name}" />
    </p:column>

  <p:column width="100">
    <f:facet name="header">
      <h:outputText value="Katalog Desc"/>
    </f:facet>
    <h:outputText value="#{catalog.description}"/>
  </p:column>

  <p:column>
  <p:commandButton action="#{formProductRelationView.updateProductListForSelectedCatalog()}"
                                                update=":main_form:selectProductTable"
        value="Bring Products">
    </p:commandButton>
    </p:column>
</p:treeTable>

Bean:

@Component("catalogSelectBean")
@Scope("request")
public class CatalogSelectBean implements Serializable {

    private static final long serialVersionUID = 1L;

    @Autowired
    private CatalogService catalogService;
    private TreeNode root;
    private TreeNode selectedNode;  


    private DualListModel<Catalog> pickListCatalogs;


    public TreeNode getRoot() {
        return root;
    }

    public TreeNode getSelectedNode() {
        return selectedNode;
    }

    public void setSelectedNode(TreeNode selectedNode) {
        this.selectedNode = selectedNode;
    }

    public void onNodeSelect(NodeSelectEvent event) {
        Catalog g = (Catalog)event.getTreeNode().getData();
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", g.getName());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }

    public CatalogSelectBean() {
    }

    @PostConstruct
    public void unLoad(){

        createRoot();
        createPickListModel();
    }


    private void createPickListModel() {
        //Players  
        List<Catalog> source = catalogService.loadChilds(catalogService.getRootCatalog());
        List<Catalog> target = new ArrayList<Catalog>();  

        pickListCatalogs = new DualListModel<Catalog>(source, target);  

    }

    private void createRoot() {
        Catalog g = null ;

            g = catalogService.getRootCatalog();

        root = new DefaultTreeNode("Root", null);

        TreeNode caRoot = new DefaultTreeNode(g,root);
        generateTree(caRoot,g);

    }

    private void generateTree(TreeNode subRoot, Catalog g) {

        for(Catalog p : g.getChildCatalogs()){
            TreeNode node0 = new DefaultTreeNode(p,subRoot);
            if(p.getChildCatalogs()!= null && p.getChildCatalogs().size()>0)
                generateTree(node0, p);
        }
    }

    public void resetTree() {
        root.setSelected(false);
    }



    public DualListModel<Catalog> getPickListCatalogs() {
        return pickListCatalogs;
    }



}

我还有一个 formProductRelationView bean,它具有 updateProductListForSelectedCatalog() 方法。

感谢您的关注。

I download primefaces 3.1, add to my project tried to add a commandButton/commandLink into a column of a treeTable
but action of commandButton/commandLink in a column is not invoked except the root row.

What may the problem be? Thanks

EDIT:

treeTable in xhtml:

<p:treeTable var="catalog" value="#{catalogSelectBean.root}" lazy="true" selection="#{catalogSelectBean.selectedNode}" selectionMode="single">
    <p:column>
        <f:facet name="header">
        <h:outputText value="Katalog Name" />
        </f:facet>
        <h:outputText value="#{catalog.name}" />
    </p:column>

  <p:column width="100">
    <f:facet name="header">
      <h:outputText value="Katalog Desc"/>
    </f:facet>
    <h:outputText value="#{catalog.description}"/>
  </p:column>

  <p:column>
  <p:commandButton action="#{formProductRelationView.updateProductListForSelectedCatalog()}"
                                                update=":main_form:selectProductTable"
        value="Bring Products">
    </p:commandButton>
    </p:column>
</p:treeTable>

Bean:

@Component("catalogSelectBean")
@Scope("request")
public class CatalogSelectBean implements Serializable {

    private static final long serialVersionUID = 1L;

    @Autowired
    private CatalogService catalogService;
    private TreeNode root;
    private TreeNode selectedNode;  


    private DualListModel<Catalog> pickListCatalogs;


    public TreeNode getRoot() {
        return root;
    }

    public TreeNode getSelectedNode() {
        return selectedNode;
    }

    public void setSelectedNode(TreeNode selectedNode) {
        this.selectedNode = selectedNode;
    }

    public void onNodeSelect(NodeSelectEvent event) {
        Catalog g = (Catalog)event.getTreeNode().getData();
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", g.getName());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }

    public CatalogSelectBean() {
    }

    @PostConstruct
    public void unLoad(){

        createRoot();
        createPickListModel();
    }


    private void createPickListModel() {
        //Players  
        List<Catalog> source = catalogService.loadChilds(catalogService.getRootCatalog());
        List<Catalog> target = new ArrayList<Catalog>();  

        pickListCatalogs = new DualListModel<Catalog>(source, target);  

    }

    private void createRoot() {
        Catalog g = null ;

            g = catalogService.getRootCatalog();

        root = new DefaultTreeNode("Root", null);

        TreeNode caRoot = new DefaultTreeNode(g,root);
        generateTree(caRoot,g);

    }

    private void generateTree(TreeNode subRoot, Catalog g) {

        for(Catalog p : g.getChildCatalogs()){
            TreeNode node0 = new DefaultTreeNode(p,subRoot);
            if(p.getChildCatalogs()!= null && p.getChildCatalogs().size()>0)
                generateTree(node0, p);
        }
    }

    public void resetTree() {
        root.setSelected(false);
    }



    public DualListModel<Catalog> getPickListCatalogs() {
        return pickListCatalogs;
    }



}

Also i have a formProductRelationView bean which has the updateProductListForSelectedCatalog() method.

Thanks for attention.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文