简体   繁体   English

JSF 2 + Richfaces 4.2.3 - <a4j:ajax> 如果不会完成 <rich:pickList> 在里面 <h:form>

[英]JSF 2 + Richfaces 4.2.3 - <a4j:ajax> will not complete if <rich:pickList> is in the <h:form>

I'm having trouble with a a4j:ajax tag inside ah:form when there is either a rich:pickList or a rich:orderingList in the same form. 我在a4j:ajax标签里面遇到麻烦啊:当有一个rich:pickList或者一个rich:ordersList时,表单形式相同。 What happens is that the ajax request is not completed and the listener method in my backing bean is not fired. 会发生什么是ajax请求没有完成,并且我的支持bean中的监听器方法没有被触发。 The onbegin event is raised, but the oncomplete isnt. 引发了onbegin事件,但是oncomplete不是。 This is really strange. 这真的很奇怪。

If i change the component to a rich:select or other similar, the ajax works properly. 如果我将组件更改为rich:select或其他类似组件,则ajax可以正常工作。

Here's part of my code. 这是我的代码的一部分。

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:s="http://jboss.org/schema/seam/taglib"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:a="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich" 
        xmlns:a4j="http://richfaces.org/a4j" 
        template="layout/template.xhtml">
        <ui:define name="body">
            <h:form id="perfil" styleClass="edit">
                <rich:panel>

                        <a4j:outputPanel id="outputPanel">
                    <s:decorate id="nomeField" template="layout/edit.xhtml">
                        <ui:define name="label">Nome</ui:define>
                        <h:inputText id="nome" size="100" maxlength="100"
                            value="#{perfilHome.instance.nome}">
                            <a4j:ajax event="blur" onbegin="alert('begin');"
                                oncomplete="alert('complete');" bypassUpdates="true" render="outputPanel" 
                                listener="#{perfilHome.test()}" />
                        </h:inputText>
                    </s:decorate>
                </a4j:outputPanel>
                    <s:decorate id="descricaoField" template="layout/edit.xhtml">
                        <ui:define name="label">Descrição</ui:define>
                        <h:inputTextarea id="descricao" required="true" cols="100" rows="4" value="#{perfilHome.instance.descricao}" />
                    </s:decorate>
    <s:decorate id="permissoesField" template="layout/edit.xhtml">          
                     <rich:pickList required="true" styleClass="picklist" style="border: none; background: transparent;" 
                        collectionType="java.util.ArrayList" immediate="false" 
                        id="permissaoPickList" 
                        value="#{perfilHome.instance.permissoes}"
                        listWidth="165px" listHeight="100px" orderable="true">
                        <f:selectItems id="permissoesItens" value="#{perfilHome.listarPermissoes()}" var="permissao"
                            itemValue="#{permissao}" itemLabel="#{permissao.nome}" />
                        <s:convertEntity />
                    </rich:pickList>                                
                </s:decorate>                               </rich:panel>
                <div class="actionButtons">
                    <h:commandButton id="save" value="Salvar"
                        action="#{perfilHome.persist}" disabled="#{!perfilHome.wired}"
                        rendered="#{!perfilHome.managed}">
                        <s:conversationId />
                    </h:commandButton>
                    <h:commandButton id="update" value="Salvar"
                        action="#{perfilHome.update}" rendered="#{perfilHome.managed}">
                        <s:conversationId />
                    </h:commandButton>
                    <h:commandButton id="delete" value="Deletar"
                        action="#{perfilHome.remove}" immediate="true"
                        rendered="#{perfilHome.managed}" />                                 </div>
            </h:form>
<s:button id="cancelEdit" value="Cancelar" propagation="end"
                        view="/Perfil.xhtml" rendered="#{perfilHome.managed}" />
                    <s:button id="cancelAdd" value="Cancelar" propagation="end"
                        view="/#{empty perfilFrom ? 'PerfilList' : perfilFrom}.xhtml"
                        rendered="#{!perfilHome.managed}" />
        </ui:define>
    </ui:composition>

As i said, i've only observed this behaviour with pickList and orderingList. 正如我所说,我只是用pickList和orderingList观察到了这种行为。 Has anyone had any problem like that? 有没有人有这样的问题?

My second question is that if i put both s:buttons inside the form, the ajax is also not being fired. 我的第二个问题是,如果我在表单中放入两个s:按钮,那么ajax也不会被触发。 Is there an explanation for that? 对此有解释吗?

I'm using JSF 2.1.14 + RichFaces 4.2.3 + Seam 2.3.0 我正在使用JSF 2.1.14 + RichFaces 4.2.3 + Seam 2.3.0

Thanks 谢谢

UPDATE 01/14/2013. 更新于2013年1月14日。 Observed a stack trace i didnt notice before. 观察到我之前没有注意到的堆栈跟踪。 I think the view state is being lost. 我认为观点状态正在消失。 Tested again with many components, only noticed problem with pickList and orderingList. 再次使用许多组件进行测试,只注意到pickList和orderingList的问题。

Exception during request processing:
Caused by java.lang.NullPointerException with message: ""

com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:441)
com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:71)
com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:582)
javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:115)
com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:199)
com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397)
org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
java.lang.Thread.run(Thread.java:722)

It's most likely your <rich:pickList/> is failing conversion, causing the entire form submission to choke and the reason is quite obvious: you've not defined a converter on the list and you're trying to update a complex type to the backing bean. 你的<rich:pickList/>很可能是转换失败,导致整个表单提交窒息而且原因很明显:你没有在列表中定义转换器而你正在尝试将复杂类型更新为支持豆。 Unless your value binding is a regular java type and not a pojo, it's mandatory you implement and define a JSF converter on the <f:selectItems/> . 除非你的value绑定是常规的java类型而不是pojo,否则你必须在<f:selectItems/>上实现和定义一个JSF转换器。 Try to confirm this by placing a <h:messages/> in the view to display validation/conversion errors 尝试通过在视图中放置<h:messages/>来确认这一点,以显示验证/转换错误

This is also a good reason why it's advisable to section your JSF components into smaller forms as against the gigantic one you have now; 这也是为什么建议将JSF组件分成较小的形式而不是现在的巨大形式的一个很好的理由; way easier to debug with a smaller form 使用较小的表单更容易调试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM