近日學netbeans6.1時發(fā)現(xiàn)一個關(guān)于visual web javaserver faces 的一個致命bug
描述如下:
創(chuàng)建或重用一個起始頁。添加一個“靜態(tài)文本”組件,將它的
text
屬性設(shè)置為
Hello
,并設(shè)置它的
id
屬性為
helloText
添加一個“按鈕”組件。雙擊“按鈕”組件編輯它的 action 方法(
button1_action
)并用以下的代碼替換方法體里的內(nèi)容
代碼范例 1:button1_action 方法
this.helloText.setText("Good Bye");
return null;
顯示如下錯誤:
找不到符號
符號: 變量 helloText
由于關(guān)于visual web javaserver faces 幫助內(nèi)容不多,各種辦法都想過了后來下載netbeans6.01又試了一下,才發(fā)現(xiàn)原委
在 netbeans6.01 環(huán)境下每在設(shè)計面板上添加一個組件,java代碼編輯處便增加一條 對應的import 語句如下
1,在設(shè)計面板上什么組件也沒有時,有以下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,在設(shè)計面板上添加組件后,有以下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 環(huán)境下也能通過測試;
而在 netbeans 6.1 環(huán)境下
1,在設(shè)計面板上什么組件也沒有時,有以下import 2條語句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
2,在設(shè)計面板上添加組件后,有以下import 語句:
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
還是兩條 import 語句
即使把全部import語句(如下)都加到netbeans 6.1 環(huán)境下
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關(guān)鍵字仍無法引用所建組建
我想這應是呢netbeans6.1 在visual web javaserver faces 方面的一個bug
王福華 2008-5-24