使用JSF 1.2&显示Rich Modal面板时出错富有的面孔

时间:2012-05-13 23:48:58

标签: richfaces jsf-1.2 modalpopups

我在使用JSF 1.2&amp ;;显示模态面板时遇到问题富有的面孔。由于项目限制,我必须使用jsp。 a4j commandLink确实提交给服务器,它返回浏览器,浏览器闪烁,但没有显示。

这是我在jsp中使用的片段

....
....
<f:view>
....
....
<h:form id="buildForm">
....
....
    <a4j:commandLink id="showItem" action="#{popupBean.selectAttributeAction}" oncomplete="Richfaces.showModalPanel('modalPanelId',{width:550, top:200});" reRender="modalPanelId">
        Click Here!
    </a4j:commandLink>
    <rich:modalPanel id="modalPanelId" width="350" height="100">
         <!-- the external content is loaded inside this tag -->
         <div id="modalPanelResult">
              This is test modal popup
          </div>
    </rich:modalPanel>
....
....
</h:form>
</f:view>
....

这是我在jsp

中包含上述片段时遇到的错误
panel.component is undefined

...,opts);});};Richfaces.hideModalPanel=function(id,opts,event){var panel=$(id);if(...

如果我在单独的Test jsp(如下所示)中使用它 - 我创建它来测试,它可以正常工作。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ 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"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<f:view>
    <a4j:commandLink id="showItem" action="#{popupBean.selectAttributeAction}" oncomplete="Richfaces.showModalPanel('modalPanelId',{width:550, top:200});" reRender="modalPanelId">
        Click Here!
    </a4j:commandLink>
    <rich:modalPanel id="modalPanelId" width="350" height="100">
         <!-- the external content is loaded inside this tag -->
         <div id="modalPanelResult">
              This is test modal popup
          </div>
    </rich:modalPanel>
</f:view>
</body>
</html>

谢谢,我感谢你们的任何帮助。我花了几天时间努力做到这一点。我有另一个css解决方案,我用a4j jsfunction调用服务器来获取弹出窗口的信息并显示叠加弹出窗口但是在Chrome中不起作用,它在IE中工作,jquery脚本代码中的脚本错误而不是我的代码,但在Firefox中工作正常,也就是当我切换到Richfaces解决方案时认为它看起来非常简单但是一旦我将测试工作(在单独的页面上)解决方案包含在我的jsp中它就不起作用。

2 个答案:

答案 0 :(得分:1)

您是否尝试过以下代码:

<a4j:commandLink id="showItem" action="#{popupBean.selectAttributeAction}" reRender="modalPanelId">
    Click Here!
<rich:componentControl for="modalPanelId" attachTo="showItem" operation="show" event="onclick" />
</a4j:commandLink>

? 如果没有,请做,在这里工作

答案 1 :(得分:0)

以下是如何打开rich:modalPanel

的示例
<%@ 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"%>
<f:view>
    <head>
        <title>User Registration</title>
    </head>
    <body>
        <jsp:include page="/views/common/styles.jsp"></jsp:include>
        <h:form id="userRegistrationForm">
            <table cellpadding="0" cellspacing="0" border="0" align="center">
                <tr class="rowspace5px"></tr>
                <tr>
                    <td>
                        <table cellpadding="0" cellspacing="3" border="0">
                            <tr>
                                <td>
                                    <h:outputText styleClass="mandatorymarkwidth error" value="*"></h:outputText>
                                </td>
                                <td class="lblwidthfirstpair">
                                    <h:outputText styleClass="labelfont" value="Security Question"></h:outputText>
                                </td>
                                <td>
                                    <h:inputText id="textSecurityQuestionId" styleClass="controlfont" disabled="true" value="#{UserRegistrationBean.textSecurityQuestion}"></h:inputText>
                                </td>
                                <td>
                                    <h:commandButton image="/images/Add_Icon.gif" onclick="Richfaces.showModalPanel('securityQuestionPanel'); return false;">
                                        <a4j:support event="onclick" reRender="userRegistrationForm" oncomplete="Richfaces.showModalPanel('securityQuestionPanel');"></a4j:support>
                                    </h:commandButton>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </h:form>
        <rich:hotKey key="esc" handler="Richfaces.hideModalPanel('securityQuestionPanel');"></rich:hotKey>
        <rich:modalPanel id="securityQuestionPanel" moveable="false" width="450" height="280" resizeable="false">
            <f:facet name="header">
                <h:outputText value="Security Question"></h:outputText>
            </f:facet>
            <f:facet name="controls">
                <h:panelGroup>
                    <h:graphicImage id="securityQuestionImage" value="../../images/close.png" styleClass="hidelink" style="cursor: pointer;" />
                    <rich:componentControl for="securityQuestionPanel" attachTo="securityQuestionImage" operation="hide" event="onclick" />
                </h:panelGroup>
            </f:facet>
            <a4j:form id="securityQuestionForm">
                <table border="0" cellspacing="0" cellpadding="0" width=100%>
                    <tr class="trseperator5"></tr>
                    <tr>
                        <td>
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tr>
                                    <td class="lblwidthfirstpair">
                                        .
                                        .
                                        .
                                        .
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr class="trseperator3"></tr>
                </table>
            </a4j:form>
        </rich:modalPanel>
    </body>
</f:view>