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(...

テスト用に作成した別のテスト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>

ありがとう、皆さんからの助けに感謝します。私はこれを行うのに苦労して数日を費やしました。サーバーへのa4j jsfunction呼び出しの後にポップアップの情報を取得してオーバーレイポップアップを表示するために使用した別のcssソリューションがありましたが、それは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

これは、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>
于 2013-05-31T10:10:52.447 に答える