2009-08-05 65 views
0

夥計們,由於某些原因,EL沒有告知屬性的操作。我有這個頁面test.xhtml:JSF + Facelets將bean動作視爲屬性

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core"> 

<body> 

<form action="#{TestBean.test}"> 
    <p>#{TestBean.status}</p> 
    <input type="submit" value="Test Again"/> 
</form> 

</body> 

</html> 

TestBean.status是一個字符串屬性(有一個方法的getStatus)和TestBean.test是返回「sucess」的方法。

我每次調用頁面我得到這個異常:

ERROR [STDERR] 05/08/2009 17:41:07 com.sun.facelets.FaceletViewHandler handleRenderException 
SEVERE: Error Rendering View[/etc/test/test.xhtml] 
javax.el.ELException: /etc/test/test.xhtml: Bean: test.TestBean, property: test 
    at com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:53) 
    at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39) 
    at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232) 
    at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239) 
    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580) 
    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108) 
    at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216) 
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432) 
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) 
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) 
    at java.lang.Thread.run(Unknown Source) 

也許這是一個長鏡頭,我可以形容我的環境更好。但乍一看,任何提示?

tks

回答

0

我認爲問題是忘記了jsfc屬性。

它應該是:

<form **jsfc="h:form"** action="#{TestCaseBean.test}"> 

TKS。

0

據我所知,EL沒有調用任意方法的語法。您使用的語法應用於除MapList或數組以外的其他任何內容時,將查找與名稱對應的屬性getter;點是句法糖TestBean["test"]

儘管可以爲EL作爲JSP標記庫的一部分定義自定義函數,但它們必須通過靜態方法實現。有關如何操作的更多信息,請參閱this tutorial。但是,該功能是currently in the JSR pipeline