0

我在显示带有 JSF 1.2 和丰富面孔的模态面板时遇到问题。由于项目限制,我必须使用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 中包含一个测试工作(在单独的页面上)解决方案,它就不起作用了。

4

2 回答 2

1

您是否尝试过以下代码:

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

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

于 2012-08-14T17:51:59.580 回答
0

这是如何打开丰富的示例: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>
于 2013-05-31T10:10:52.447 回答