2010-02-24 68 views
6

我創建了這個測試用例來隔離我的問題。一旦輪詢執行ajax更新,就不會執行a4j:commandLink操作。如果我們在poll的reRender之前關閉了modalPanel,它會被執行。a4j:command在reRender後停止工作

有什麼建議嗎?提前致謝。

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> 

鏈接

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這個是會話範圍。 Richfaces版本3.3.2.SR1

而且在Chrome 5.0.322.2開發中,modalPanel不會出現。它在FF和IE7下。

回答

4

嘗試以下的任何組合:

  • 動議<a4j:form>模式面板
  • 設置domElementAttachment(模態面板)的外部屬性使用要麼formparent
  • 嘗試<h:form>

請嘗試以下代替<a4j:commandLink>

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

並在modalPanel,其中notifyClose()使用<a4j:jsFunction>定義使用onhide="notifyClose()"。這是一個解決方法,但可能有效。

+0

,我從我的應用程序,它有這個問題的分量這個測試用例。該組件在「父」上有domElementAttachment,但該鏈接不起作用。我將嘗試移動窗體... – pakore 2010-02-24 14:39:54

+0

將窗體移動到modalPanel之外也無濟於事。無論如何感謝你的答案。 – pakore 2010-02-24 14:43:27

+0

@pakore - 我的意思是 - 將表格移到外面,然後擺脫第二種形式。你嘗試過嗎? – Bozho 2010-02-25 06:16:21

4

這是工作解決方案。我接受Bozho的回答是有效的,因爲他提出了在這裏實施的解決方法,但我只是在這裏發佈完整的解決方案,以防有人遇到同樣的問題。

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> 

重要的是要保持a4j:jsFunctionmodalPanel標籤是非常重要的。

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; 
    } 
}