看得懂这段代码的帮忙注释一下,最好具体点(是用netbeans写的)

来源:百度知道 编辑:UC知道 时间:2024/06/24 05:21:03
public void createTree(Tree tree, CachedRowSetDataProvider provider, String idField, String pidField, String textField, String action) {
MethodExpression methodExpression = null;
FacesContext context = FacesContext.getCurrentInstance();
if (action != null) {
Application application = context.getApplication();
ELContext elContext = context.getELContext();
methodExpression = application.getExpressionFactory().createMethodExpression(elContext, action, String.class, new Class[]{});
}
Map<String,TreeNode> map=new HashMap<String,TreeNode>();
boolean hasNext=provider.cursorFirst();
while(hasNext){
TreeNode node=new TreeNode();
String id="tree"+provider.getValue(idField);
String text=String.valueOf(provider.getValue(textField));
node.setId(id);
node

2叉树啊!
public void createTree(Tree tree, CachedRowSetDataProvider provider, String idField, String pidField, String textField, String action) {
MethodExpression methodExpression = null;
FacesContext context = FacesContext.getCurrentInstance(); //取得当前实例
if (action != null) {
Application application = context.getApplication();
ELContext elContext = context.getELContext();
methodExpression = application.getExpressionFactory().createMethodExpression(elContext, action, String.class, new Class[]{});
} //以上是一些程序化的操作,我也不太理解,基本上就是防止为空等问题。以及初始化。
Map<String,TreeNode> map=new HashMap<String,TreeNode>(); //新建map
boolean hasNext=provider.cursorFirst();// //建立boolean变量hasnext,重provider头开始。
while(hasNext){
TreeNode node=new TreeNode();
String id="tree"+provider.getValue(idField); //拼接字符串,从provider中取得idfield。
String text=String.valueOf(provider.getValue(textField)); //取得text
node.setId(id); //se