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);
}
}}
}
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);
}
}}
}
我把要用的.jar包放在这里,
D:\software\Java\jdk1.6.0_10\jre\lib\ext
同时,我还有.dll放在这里,
D:\software\Java\jdk1.6.0_10\jre\bin
楼主根据自己的JAVAHOME路径,相应变换,JAVAHOME是JDK路径,不是JRE的。
最后,楼主成功后,一定要结贴给分啊。
不知怎么回事
“已经将 jsf-api.jar 放在jdk 的lib 目录下,也添加到了classpath中,能找到”放这里不对!
.jar要放我上面说的地方。
你的 jsf-api.jar 里有javax.faces.tree.Tree这个class吗? 有的话求共享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;
前四个都找到了,就是最后一个里面没有
不会是我的书是2005的太早了吗?
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;
这些没有一个我在1.6jdk理找得到的。你前几个都在哪找到的呢?最后一个应该也在那里