从ModalPanel RichFaces返回时,父窗口为空

时间:2012-08-30 04:46:06

标签: java-ee jsf-2 richfaces popupwindow

对于我的Web应用程序,我正在使用RichFaces 4.X版本ModalPanel进行弹出窗口。该应用程序在JSF2.0中并在Apache Tomcat 7上运行。现在,我的弹出窗口工作正常,但是当我关闭弹出窗口时,我的父窗口没有刷新。我可以看到父页面正在加载(因为我可以看到绑定变量的所有getter方法都被调用),但我得到的只是一个空白页面。我的Backing bean的范围是“Session”。我在这里粘贴我的JSF文件。

请让我知道我错过了什么。我整天都试过了,再也没有想到什么了。 :(

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>    
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>


<html> 
<head>

<title>ILE Designs</title> 
<script type="text/javascript">   

function actionWhenMouseOver(imgName) {  
    var img = document.getElementById(imgName); 
    img.style['width'] = "300px"; 
    img.style['height'] = "300px"; 
}

function actionWhenMouseOut(imgName) { 
    var img = document.getElementById(imgName); 
    img.style['width'] = "100px"; 
    img.style['height'] = "100px"; 
} 
</script>


</head>


<body bgcolor="000000">
<f:view>
<h:form> 

    <h:panelGrid border="0" columns="2">
            <h:graphicImage id="logo" alt="jsf-sun" width="375" height="130" url="/default/logo.gif"> 
            </h:graphicImage>
            <h:outputText style="font-family:verdana;font-size:26pt;color:white"  value="Welcome to ILE Designs Customer Portal"></h:outputText>
    </h:panelGrid>

    <h:panelGrid border="0" columns="3">   
        <h:graphicImage id="image" alt="jsf-sun" width="500" height="400" url="#{startupBean.defaultRenderedImg}"> 
        </h:graphicImage>
        <h:panelGrid style="font-family:verdana;font-size:10pt;color:black" columns="1" border="1">
                <h:outputText  value="Default"></h:outputText>
                <rich:dataTable value="#{startupBean.objectList}" var="ObjectBO" cellspacing="20">

                    <rich:column>             
                        <h:outputText style="font-family:verdana;font-size:10pt;color:black" value="#{ObjectBO.displayName}"/>                      
                    </rich:column>
                    <rich:column>      
                        <h:graphicImage width="50" height="50" id="choice" alt="jsf-sun" url="#{ObjectBO.color_url}" value="#{ObjectBO.color_url}"> 
                        </h:graphicImage>  
                    </rich:column>  
                </rich:dataTable>
            </h:panelGrid>
            <h:panelGrid id="choicetable" style="font-family:verdana;font-size:12pt;color:black" columns="1" border="1" rendered="#{startupBean.choicesFlag}">

                    <rich:dataTable id="datat" value="#{startupBean.choiceKeys}" var="mapEntry" cellspacing="20">

                    <rich:column>   

                        <h:outputText style="font-family:verdana;font-size:12pt;color:black"  value="Choice"></h:outputText><h:outputText style="font-family:verdana;font-size:10pt;color:black" value="#{mapEntry.key}"/>
                        <rich:dataTable value="#{mapEntry.value}" var="ObjectBO">
                        <rich:column>
                        <a4j:commandLink id="objs" action="#{startupBean.getCategory}" reRender="materialTree" ajaxSingle="true" oncomplete="Richfaces.showModalPanel('selectMaterial',{top:'10px', left:'10px', height:'400px', width:'400px'});" >      
                                <h:outputText style="font-family:verdana;font-size:10pt;color:black" value="#{ObjectBO.displayName}" binding="#{startupBean.outTxt}"/>
                                <f:setPropertyActionListener target="#{startupBean.key}" value="#{mapEntry.key}" />
                        </a4j:commandLink>
                        </rich:column>
                        <rich:column>      

                            <h:graphicImage width="50" height="50" id="choice" alt="jsf-sun" url="#{ObjectBO.color_url}" value="#{ObjectBO.color_url}"> 
                            </h:graphicImage>  
                        </rich:column>  
                        </rich:dataTable>
                        </rich:column>

                    </rich:dataTable>
            </h:panelGrid>
    </h:panelGrid> 
    <h:panelGrid border="0" columns="2" >
                <h:commandButton action="#{startupBean.copyDefault}" image="/default/Duplicate.png"></h:commandButton>
                <h:commandButton action="#{startupBean.renderImg}" image="/default/Previous.png"></h:commandButton>
            </h:panelGrid> 


</h:form> 

<rich:modalPanel id="selectMaterial">
    <f:facet name="header"> 
        Material Selection
    </f:facet>
    <a4j:form ajaxSubmit="true">
        <h:panelGrid id="materialTree">
            <h:panelGrid id="tree1" border="0" columns="1">  
                            <rich:tree style="width:300px" nodeSelectListener="#{startupBean.processSelection}" 
                                        reRender="colordtl" ajaxSubmitSelection="true"  switchType="client"
                                         value="#{startupBean.treeNode}" var="item">
                            </rich:tree>

                        </h:panelGrid>

                        <h:panelGrid id="colordtl" > 
                        <h:panelGrid>
                            <rich:dataTable value="#{startupBean.colorList}"  var="colorBO">

                            <f:facet name="header" >
                              <h:outputText value="Colors"/>
                            </f:facet>
                            <rich:column>

                            <a4j:commandLink id="color" actionListener="#{startupBean.getColor}"> 
                                 <h:graphicImage width="100" height="100" id="colors" alt="jsf-sun" url="#{colorBO.color_url}" value="#{colorBO.color_url}" binding="#{startupBean.graphicColor}" > 
                                </h:graphicImage> 
                            </a4j:commandLink>

                    </rich:column>
                </rich:dataTable>
        </h:panelGrid>
                   <h:panelGrid border="0" columns="4">
                <h:outputText value="Please select from the below options" >        
                </h:outputText>    

                <h:selectOneMenu value="#{startupBean.selectedPattern}" >         
                    <f:selectItems value="#{startupBean.selectPattern}" /> 
                </h:selectOneMenu>

                <h:selectOneMenu value="#{startupBean.selectedFinish}" >         
                    <f:selectItems value="#{startupBean.selectFinish}" /> 
                </h:selectOneMenu>
            </h:panelGrid>
            </h:panelGrid>
            <h:panelGrid columns="1">
                <a4j:commandButton image="/default/Add1.png" oncomplete="#{Richfaces.hideModalPanel('selectMaterial')};"></a4j:commandButton>
            </h:panelGrid>
        </h:panelGrid>
    </a4j:form>
</rich:modalPanel>
</f:view>
</body>
</html>

另外,在ModalPanel commandButton oncomplete方法中,我尝试了返回true和false。

谢谢, 简

1 个答案:

答案 0 :(得分:1)

您的父页面似乎根本没有刷新。那是因为你需要reRender你要刷新的父页面上的组件:

<a4j:commandButton image="/default/Add1.png" 
       reRender="someComponentId(s) on the parent page" 
            oncomplete="Richfaces.hideModalPanel('selectMaterial');">