1

おそらく簡単な仕事に直面していて、間違った方向に歩いているように感じます. ユーザーがデフォルトのランディング ページにアクセスしたときにポップアップが必要です。このポップアップには、iframe などで外部 Web ページ (シングル サインオンでは回避できないログイン情報) が表示されます。一部のユーザーのみがこのダイアログを使用する必要があるため、このポップアップが再び表示されないようにする機会を与えたいと考えています (Cookie または DB によって、このオプションを管理者が手動でリセットする必要がある場合は問題ありません)。したがって、基本的には、iframe を使用した「Do not ask again」ポップアップが必要です。

サイズのないランディング ページに MVC ポートレットを配置することにしました。ポップアップのみ。私が持っているのは、iframe、チェックボックス、およびポップアップが閉じたときにそのチェックボックスから情報を取得できないため、これは間違った方法であるという感覚を備えた AlloyUI ポップアップです。

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />

<aui:script>

    AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', 'console',
        function(A) {

            var bodyNode = A.Node.create('<div><iframe src="http://www.dummysite.com"></iframe> </div>');
            var footerNode = A.Node.create('<input name="donotaskagain" type="checkbox"></input> <label for="donotaskagain">Do not ask again</label>');

            var dialog = new A.Dialog({
                title: 'DISPLAY CONTENT',
                centered: true,
                modal: true,
                resizable: false,
                width: 510,
                height: 430,
                bodyContent: bodyNode,
                footerContent: footerNode
            });
            dialog.render();
        }
    );
</aui:script>

これで私を助けてくれることを願っています。そのコンテキストで JSP、AlloyUI、および Java を適切に使用する方法に関するすべての背景情報をいただければ幸いです。

4

1 に答える 1

0

ユーザーが保存ボタンを押したときに送信されるポップアップのフッターにフォームを導入することで、この問題を回避しました。ページを更新する必要があるため最適ではありませんが、ポップアップは発生しないため、許容されます。おそらく、他の誰かが AJAX を使用してソリューションを投稿できるので、この動作はよりスムーズになります。

まず、view.jsp を用意します。

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />

<portlet:actionURL name="storeDoNotAskAgain" var="storeDoNotAskAgainURL"></portlet:actionURL>

<!-- Check here whether or not the popup should be shown. We used JSP tags (an "if" around the script) 
    and a JAVA helper class to access the Expandobridge to get a variable from the Liferay DB 
    to decide whether or not the user had chosen not to display the popup again.
<!--  Create Alloy UI dialog with iframe pointing to the specified site as a body and form as footer.
    The form can be submitted to store the "do not ask again"-checkbox value in DB. 
    It is connected with an action from of the portlet. -->
<aui:script>

    AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain',
        function(A) {

            var bodyNode = A.Node.create('<div><iframe src="http://www.dummysite.com"> </iframe> </div>');
            var footerNode = A.Node.create('<form action="<%= storeDoNotAskAgainURL%>" method="post"><input type="submit" value="Save" class="submit"><input name="donotaskagain" type="checkbox"></input> <label for="donotaskagain">Do not ask again.</label></form>');

            var dialog = new A.Dialog({
                title: "Title",
                bodyContent: bodyNode,
                footerContent: footerNode
            });
            dialog.render();
        }
    );
</aui:script>

次に、フォームが参照するストア アクションを処理する新しいポートレット メイン クラスを作成しました。

package com.example.portlet;

import ...

public class MyPortlet extends MVCPortlet {

    @ProcessAction(name = "storeDoNotAskAgain")
    public void storeDoNotAskAgain(ActionRequest request, ActionResponse response) throws Exception {
        boolean val = ParamUtil.getBoolean(request, "donotaskagain", false);
        // store boolean in db or a file
    }
}

形式: portlet.xml を調整して、ポートレットのメイン クラスが新しいポートレット クラスを指すようにする必要があります。

<portlet-class>com.example.portlet.MyPortlet</portlet-class>
于 2013-07-11T09:50:28.477 に答える