2010-02-24 20 views
6

He creado este caso de prueba que aísla mi problema. La acción a4j: commandLink no se ejecuta una vez que la encuesta realiza una actualización de Ajax. Se ejecuta si cerramos el modalPanel antes de reRender de la encuesta.a4j: commandLink deja de funcionar después de ser reRender

¿Alguna sugerencia? Gracias por adelantado.

test.xhtml:

<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" 
xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:c="http://java.sun.com/jsp/jstl/core" 
xmlns:fnc="http://eyeprevent.com/fnc"> 
<a4j:outputPanel id="testing"> 
<rich:modalPanel id="examinationPanel" autosized="true" width="450" rendered="#{test.condition2}"> 
    <f:facet name="header"> 
     <h:outputText value="View Examination Images" /> 
    </f:facet> 
    <f:facet name="controls"> 
     <h:panelGroup> 

      <a4j:form> 

       <a4j:commandLink action="#{test.close}"> 
        <h:graphicImage value="/images/modal/close.png" id="hideExaminationPanel" styleClass="hidelink" /> 
       </a4j:commandLink> 
      </a4j:form> 
      <rich:componentControl for="examinationPanel" attachTo="hideExaminationPanel" operation="hide" event="onclick" /> 

     </h:panelGroup> 
    </f:facet> 


    <a4j:form> 

     <h:panelGrid columns="1" id="timeoutText"> 
      <h:outputText id="remainingtime" value="condition1" rendered="#{test.condition1}" /> 
      <h:outputText id="timer" value="condition2" rendered="#{test.condition2}" /> 

     </h:panelGrid> 

     <a4j:poll id="poll" interval="5000" enabled="#{test.poll}" reRender="poll,timeoutText" /> 



    </a4j:form> 
</rich:modalPanel> 

Enlace

TestBean.java

import org.apache.log4j.Logger; 
public class TestBean { 
private boolean condition1=false; 
private boolean condition2=true; 
private boolean poll=true; 

public void close(){ 
Logger.getLogger("com.eyeprevent").info("here!"); 
poll=false; 
condition1=true; 
condition2=false; 

} 

public boolean isCondition1() { 
return condition1; 
} 

public void setCondition1(boolean condition1) { 
this.condition1 = condition1; 
} 

public boolean isCondition2() { 
return condition2; 
} 
public void setCondition2(boolean condition2) { 
this.condition2 = condition2; 
} 
public boolean isPoll() { 
return poll; 
} 
public void setPoll(boolean poll) { 
this.poll = poll; 
} 
} 

testBean es sesión en ámbito. Richfaces versión 3.3.2.SR1

Y también en Chrome 5.0.322.2 dev el modalPanel no aparece. Lo hace bajo FF e IE7.

Respuesta

4

Trate cualquier combinación de los siguientes:

  • movimiento la <a4j:form> fuera del panel modal
  • establece la domElementAttachment (del panel modal) atribuir a cualquiera de form o parent
  • intentar usar <h:form>

Pruebe lo siguiente en lugar de <a4j:commandLink>:

<h:graphicImage value="/images/modal/close.png" styleClass="hidelink" 
      onclick="#{rich:component('examinationPanel')}.hide()" id="close" /> 

y utilizar onhide="notifyClose()" en la modalPanel, donde notifyClose() se define utilizando <a4j:jsFunction>. Esto es un poco de una solución, pero podría funcionar.

+0

Tengo este caso de prueba de un componente en mi aplicación que tiene este problema. El componente tiene domElementAttachment en "parent", pero el enlace no funciona. Voy a intentar mover el formulario ... – pakore

+0

Mover el formulario fuera del modalPanel tampoco ayuda. Gracias de todos modos por la respuesta. – pakore

+0

@pakore - Me refiero a - mover el formulario fuera, y deshacerse de la segunda forma. ¿Lo intentaste? – Bozho

4

Esta es la solución de trabajo. Acepté la respuesta de Bozho como válida porque propuso la solución que se implementa aquí, pero acabo de publicar la solución completa aquí en caso de que alguien tenga el mismo problema.

test.xhtml:

<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" 
xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:c="http://java.sun.com/jsp/jstl/core" 
xmlns:fnc="http://eyeprevent.com/fnc"> 
<a4j:outputPanel id="testing"> 
<rich:modalPanel id="examinationPanel" autosized="true" width="450" rendered="#{test.condition2}" onhide="stopTimer('false')"> 
    <f:facet name="header"> 
     <h:outputText value="View Examination Images" /> 
    </f:facet> 
    <f:facet name="controls"> 
     <h:panelGroup> 
      <a4j:form> 
       <a4j:commandLink action="#{test.close}"> 
        <h:graphicImage value="/images/modal/close.png" id="hideExaminationPanel" styleClass="hidelink" /> 
       </a4j:commandLink> 
      </a4j:form> 
      <rich:componentControl for="examinationPanel" attachTo="hideExaminationPanel" operation="hide" event="onclick" /> 
     </h:panelGroup> 
    </f:facet> 
    <a4j:form> 
     <h:panelGrid columns="1" id="timeoutText"> 
      <h:outputText id="remainingtime" value="condition1" rendered="#{test.condition1}" /> 
      <h:outputText id="timer" value="condition2" rendered="#{test.condition2}" /> 
     </h:panelGrid> 
     <a4j:poll id="poll" interval="5000" enabled="#{test.poll}" reRender="poll,timeoutText" /> 
    </a4j:form> 
</rich:modalPanel> 
</a4j:outputPanel> 
<h:form> 
<a4j:commandLink oncomplete="#{rich:component('examinationPanel')}.show()" reRender="testing">Link</a4j:commandLink> 
<a4j:jsFunction name="stopTimer" actionListener="#{test.close}"> 
    <a4j:actionparam name="param1" assignTo="#{test.poll}" /> 
</a4j:jsFunction> 
</h:form> 
</html> 

Es importante mantener la a4j:jsFunction fuera de la etiqueta modalPanel.

TestBean.java:

import javax.faces.event.ActionEvent; 
import org.apache.log4j.Logger; 

public class TestBean { 
    private boolean condition1 = false; 
    private boolean condition2 = true; 
    private boolean poll = true; 

    public void close(ActionEvent event) { 
     Logger.getLogger("com.eyeprevent").info("here!"); 
     poll = false; 
     condition1 = true; 
     condition2 = false; 
    } 

    public boolean isCondition1() { 
     return condition1; 
    } 

    public void setCondition1(boolean condition1) { 
     this.condition1 = condition1; 
    } 

    public boolean isCondition2() { 
     return condition2; 
    } 

    public void setCondition2(boolean condition2) { 
     this.condition2 = condition2; 
    } 

    public boolean isPoll() { 
     return poll; 
    } 

    public void setPoll(boolean poll) { 
     this.poll = poll; 
    } 
} 
Cuestiones relacionadas