statictreebean.java

来自「OperaMasks是一种基于J2EE的Web开发技术」· Java 代码 · 共 50 行

JAVA
50
字号
package demo.tree;

import org.operamasks.faces.annotation.Action;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.component.tree.impl.UITree;
import org.operamasks.faces.component.tree.impl.UITreeNode;
@ManagedBean(name="StaticTreeBean", scope=ManagedBeanScope.REQUEST)
public class StaticTreeBean {
    @Bind
    private UITree tree;
    
    @Bind
    private String response;
    
    @Action
    public void tree_onselect(){
        process();
    }
    
    @Action
    public void tree_oncheck(){
        process();
    }
    
    private void process(){
        response = "响应事件的节点是:"  + tree.getEventNode().getText();
        response += "<br/>";
        response += "勾中的节点是:";
        for(UITreeNode node : tree.getCheckedNodes()){
            response += node.getText() + ",";
        }
        response += "<br/>";
        response += "根节点的直接后代中半勾中的节点是:";
        for (UITreeNode node : tree.getRootNode().getPartlyCheckedChildren()) {
            response += node.getText() + ",";;
        }
        response += "<br/>";
        response += "全树范围内半勾中的节点是:";
        for (UITreeNode node : tree.getPartlyCheckedNodes()) {
            response += node.getText() + ",";
        }
        response += "<br/>";
        if(tree.getSelectedNode() != null){
            response += "选中的节点是:"  + tree.getSelectedNode().getText();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?