我需要使用ajax.requst從javascript調用JSF Bean方法。從下面的XHTML文件共享按鈕將執行一個JavaScript將運行下面的ajax功能。但是我得到了下面的錯誤。我需要在這條路線上執行ajax請求的幫助,我相信會有幾種選擇,但我希望它現在可以這樣工作。jsf.ajax.request調用JSF bean執行方法
的JavaScript
$('#shareButton').livequery("click", function() {
............................
.................
jsf.ajax.request('commandLink',null,{execute: 'commandLink',render: 'topic_guid'});
...................
.............})
XHTML
<f:form id="testForm" prependId="false">
<div id="sharebtn">
<a class="button Share" style="" id="shareButton">Share</a>
</div>
<h:inputHidden value="#{topicBean.topicVO.body}" id="topic_body"/>
<h:inputHidden value="#{topicBean.topicVO.videoAudioUrl}" id="topic_vaurl" />
<h:inputHidden value="#{topicBean.topic_guid}" id="topic_guid" />
<p:commandLink id="commandLink" action="#{topicController.createTopic}"
</f:form>
錯誤
20:38:13,793 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/emyed-web].[default]] (http--127.0.0.1-8080-6) Servlet.service() for servlet default threw exception: java.lang.NullPointerException
at com.sun.faces.mgbean.BeanManager$ScopeManager$SessionScopeHandler.handle(BeanManager.java:575) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(BeanManager.java:458) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:410) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.1.7-jbossorg-2.jar:]
at com.zreflect.emyed.filter.EmyEdAccessFilter.hasLoggedIn(EmyEdAccessFilter.java:113) [emyed-ui-1.0.jar:]
at com.zreflect.emyed.filter.EmyEdAccessFilter.doFilter(EmyEdAccessFilter.java:84) [emyed-ui-1.0.jar:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2039) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
看起來像你的錯誤是'',它應該是''或者,也許你只是貼有錯誤代碼。 –
@LuiggiMendoza其實我現在沒有得到這些錯誤,如果我改變了SessionScope而不是ViewScope.However,它不會發送參數值,如Topic_body和topic_vaurl到服務器。 – user1595858
爲什麼不能使用PrimeFaces'
'提供的ajax功能?您應該發佈您的功能需求以獲得更好的幫助。 –