2010-02-24 30 views
6

Tôi đã tạo trường hợp thử nghiệm này để tách biệt vấn đề của tôi. Hành động lệnh a4j: commandLink không được thực hiện khi cuộc thăm dò cập nhật ajax. Nó được thực thi nếu chúng ta đóng modalPanel trước khi reRender của bình chọn.a4j: commandLink ngừng hoạt động sau khi reRender

Bất kỳ đề xuất nào? Cảm ơn trước.

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> 

Liên kết

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 là phiên scoped. Richfaces phiên bản 3.3.2.SR1

Và cũng trong Chrome 5.0.322.2, deval modalPanel không xuất hiện. Nó hoạt động theo FF và IE7.

Trả lời

4

Hãy thử kết hợp bất kỳ những điều sau đây:

  • di chuyển các <a4j:form> ngoài bảng modal
  • thiết lập domElementAttachment (của bảng điều khiển modal) gán cho một trong hai form hoặc parent
  • hãy thử sử dụng <h:form>

Hãy thử các mục sau thay vì <a4j:commandLink>:

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

và sử dụng onhide="notifyClose()" trên modalPanel, nơi notifyClose() được định nghĩa sử dụng <a4j:jsFunction>. Đây là một chút của một workaround, nhưng có thể làm việc.

+0

tôi đã kiểm tra trường hợp này từ một thành phần trong ứng dụng của tôi trong đó có vấn đề này. Các thành phần có domElementAttachment trên "cha mẹ", nhưng liên kết không hoạt động. Tôi sẽ cố gắng di chuyển biểu mẫu ... – pakore

+0

Di chuyển biểu mẫu bên ngoài modalPanel cũng không giúp được gì. Cảm ơn anyway cho câu trả lời. – pakore

+0

@pakore - Ý tôi là - di chuyển biểu mẫu bên ngoài và loại bỏ biểu mẫu thứ hai. Bạn đã thử điều đó chưa? – Bozho

4

Đây là giải pháp làm việc. Tôi chấp nhận câu trả lời của Bozho là hợp lệ bởi vì ông đã đề xuất cách giải quyết được thực hiện ở đây, nhưng tôi chỉ đăng giải pháp hoàn chỉnh ở đây trong trường hợp ai cũng có cùng một vấn đề.

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> 

Điều quan trọng là để giữ a4j:jsFunction bên ngoài của thẻ 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; 
    } 
} 
Các vấn đề liên quan