MyActionListener.java:8: 软件包 javax.faces.tree 不存在
import javax.faces.tree.Tree;已经将 jsf-api.jar 放在jdk 的lib 目录下,也添加到了classpath中,能找到
javax.faces.component.UIComponent
打开jsf-api.jar jsf-ri.jar jsf-impl.jar中都找不到javax.faces.tree.Tree
求高手解答啊 。。这是我的第一个JSF例子。。代码。。
package ch01a;import java.util.Iterator;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.faces.tree.Tree;public class MyActionListener
{
public PhaseId getPhaseId(){
System.out.println("getPhaseId called..");
return PhaseId.APPLY_REQUEST_VALUES;
} public void processAction(ActionEvent event){
System.out.println("processAction called");
//the componet that trigegered the action event
UIComponent component =event.getComponent();
System.out.println(
"The id of the component that fired the action event:"
+component.getComponentId());
//the action command
String actionCommand=event.getActionCommand();
System.out.println("Action command :"+actionCommand); FacesContext facesContext=FacesContext.getCurrentInstance();
Tree tree=facesContext.getTree();
UIComponent root=tree.getRoot();
System.out.println("---------Component Tree------------");
navigateComponentTree(root,0);
System.out.println("-----------------------------------");
} private void navigateComponentTree(UIComponent root,int level){
//indent
for(int  i=0;i<level;i++){
System.out.print(" ");
//print component id
System.out.println(component.getComponentId());
Iterator children=component.getChildren();
//navigate children
while(children.hasNext){
UIComponent child=(UIComponent)children.next();
navigateComponentTree(child,level+1);
}
} }
}