将附加参数发送到p:jax事件侦听器

时间:2017-11-03 10:22:50

标签: ajax jsf jsf-2.2

我的XHTML

中有以下内容
<h:selectBooleanCheckbox value="" id="negative">
    <f:attribute name="myParam" value="#{drugs.pkgId}" />
    <p:ajax process="@this" event="change" listener="#{contolerYYY.viewItem}" />
</h:selectBooleanCheckbox>

我尝试在我的控制器中访问以下内容,

public void viewItem(SelectEvent event) {
    String myParam= (String) event.getComponent().getAttributes().get("myParam");
    logger.info("viewItem : " + myParam);
}

但每当我单击复选框时,我都会收到以下异常,并且控件不会转到该方法。

15:49:45,506 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-/127.0.0.1:443-3) javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: /myFile.xhtml @243,68 value="": JBWEB006018: Illegal Syntax for Set Operation
    at javax.faces.component.UIInput.updateModel(UIInput.java:857)
    at javax.faces.component.UIInput.processUpdates(UIInput.java:739)
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:538)
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1652)
    at org.primefaces.component.api.UIData.visitColumnContent(UIData.java:1014)
    at org.primefaces.component.api.UIData.visitRows(UIData.java:988)
    at org.primefaces.component.api.UIData.visitTree(UIData.java:842)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
    at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:383)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:257)
    at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57)
    at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57)
    at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
    at org.omnifaces.context.OmniPartialViewContext.processPartial(OmniPartialViewContext.java:143)
    at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1221)
    at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at net.stafftrack.ui.web.security.filter.SecurityFilter.processSTNRequest(SecurityFilter.java:132)
    at net.stafftrack.ui.web.security.filter.SecurityFilter.doFilter(SecurityFilter.java:58)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512)
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.el.PropertyNotWritableException: /myFile.xhtml @243,68 value="": JBWEB006018: Illegal Syntax for Set Operation
    at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:136)
    at javax.faces.component.UIInput.updateModel(UIInput.java:822)
    ... 48 more

我的目的是通过Ajax向方法发送一个值,并且可以帮助我找出原因。

1 个答案:

答案 0 :(得分:0)

当我将方法签名更改为viewItem(AjaxBehaviorEvent event)

时,它有效

由于