简体   繁体   中英

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. What happens is that the ajax request is not completed and the listener method in my backing bean is not fired. The onbegin event is raised, but the oncomplete isnt. This is really strange.

If i change the component to a rich:select or other similar, the ajax works properly.

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. 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. Is there an explanation for that?

I'm using JSF 2.1.14 + RichFaces 4.2.3 + Seam 2.3.0

Thanks

UPDATE 01/14/2013. 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.

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. 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/> . Try to confirm this by placing a <h:messages/> in the view to display validation/conversion errors

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; way easier to debug with a smaller form

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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