我有以下问题!
在我的一个网站上,我有一个按钮:
<h:commandButton value="IDA Analyzer Results" action="#{SelectionBean.monitoringLog()}"/>
它使用 bean 的某些部分调用的方法:
@ManagedBean(name = "SelectionBean")
@SessionScoped
public class TableSelectionBean {
private List<String> analyzerLog = new ArrayList<String>();
public String monitoringLog() throws FileNotFoundException, IOException{
String fileName = "/opt/IDA2/Linux/bin/"+"filtered_"+selectionMonitoringData.get(0).getMonitoringName()+"_result.txt";
if(selectionMonitoringData.get(0).getIsExecuted())
{
BufferedReader br = new BufferedReader(new FileReader(fileName));
try {
String line;
while ((line=br.readLine()) != null) {
getAnalyzerLog().add(line);
}
} finally {
br.close();
System.out.println(getAnalyzerLog());
}
}
return "analyzerresult.xhtml";
}
在我单击此按钮后,如您所见,它会将我导航到另一个页面:
<h:body>
<h:form>
<h:commandButton value="hi" action="#{AnalyzerBean.myMethod()}"></h:commandButton>
</h:form>
</h:body>
这是豆:
@ManagedBean(name = "AnalyzerBean")
@SessionScoped
public class AnalyzerResultBean {
@ManagedProperty(value="#{SelectionBean.analyzerLog}")
private List<String> analyzerLog;
public void myMethod(){
System.out.print(analyzerLog);
}
/**
* @return the analyzerLog
*/
public List<String> getAnalyzerLog() {
return analyzerLog;
}
/**
* @param analyzerLog the analyzerLog to set
*/
public void setAnalyzerLog(List<String> analyzerLog) {
this.analyzerLog = analyzerLog;
}
因此,当我尝试使用此托管属性时,它会说:
表达式 #{SelectionBean.analyzerLog} 引用的对象的范围,视图,比会话的引用托管 bean (AnalyzerBean) 范围短,但正如您所见,两者都是 Session Scoped。可能是什么问题呢?