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