近日学netbeans6.1时发现一个关于visual web javaserver faces 的一个致命bug
描述如下:
创建或重用一个起始页。添加一个“静态文本”组件,将它的
text
属性设置为
Hello
,并设置它的
id
属性为
helloText
添加一个“按钮”组件。双击“按钮”组件编辑它的 action 方法(
button1_action
)并用以下的代码替换方法体里的内容
代码范例 1:button1_action 方法
this.helloText.setText("Good Bye");
return null;
显示如下错误:
找不到符号
符号: 变量 helloText
由于关于visual web javaserver faces 帮助内容不多,各种办法都想过了后来下载netbeans6.01又试了一下,才发现原委
在 netbeans6.01 环境下每在设计面板上添加一个组件,java代码编辑处便增加一条 对应的import 语句如下
1,在设计面板上什么组件也没有时,有以下import 语句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import javax.faces.FacesException;
2,在设计面板上添加组件后,有以下import 语句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.StaticText;
import javax.faces.FacesException;
多了两条 import 语句
代码在netbeans 6.01 环境下也能通过测试;
而在 netbeans 6.1 环境下
1,在设计面板上什么组件也没有时,有以下import 2条语句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
2,在设计面板上添加组件后,有以下import 语句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
还是两条 import 语句
即使把全部import语句(如下)都加到netbeans 6.1 环境下
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.StaticText;
import javax.faces.FacesException;
亦显示以下语句为无用导入
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.StaticText;
且this关键字仍无法引用所建组建
我想这应是呢netbeans6.1 在visual web javaserver faces 方面的一个bug
王福华 2008-5-24