2016-09-29 5 views
0

TomcatサーバーにLiferay 6サーバーがあります。Liferayサーバーで簡単なサーブレットを設定する

私の公開ページ(歓迎の1つ)を編集中ですので、管理コンソールからJavaScriptを読み込みます。それは単にあなたが望むものであれば、ページの最後にスクリプトを置くだけです。これはうまくいきました。ページの隅にポップアップを表示しています(ページについての意見を伝える典型的なポップアップ)。

ポップアップが準備完了しました私は書式をから請願書を送るにはサーブレットが必要ですが、Liferay Serverで単純なJavaサーブレットを作成する方法はわかりません。

私はそれを独立して作成し、それをTomcatにデプロイする必要はありませんか?しかし、どのように展開すればよいのですか?Liferayの環境と衝突しないようにフックを設定するにはどうしたらいいですか?

ありがとうございました!

答えて

0

私はこのようなことを試みたことはありませんでしたが、this answerはそれを論理的に正しい方法と思われますが、それはこの状況を処理するLiferayの方法ではありません。

これは、Struts Action Hooksを使用して、ポータル全体でグローバルに到達可能な新しいアクションを作成することです。

フックのこのタイプは、コアポータル(例えばc/portal/login)をオーバーライドするために使用することができ、ポートレットはアクション(例えば/login/forgot_password)を支柱、Liferayのポータルのため、このアクションは、アクションを上書きfolder.ToそのWEB-INFstruts-config.xmlファイルで指定されています

  1. liferay-hook.xmlフックプラグインのファイルdocroot/WEB-INFの下にフック要素内にstruts-action要素を追加します。

    <struts-action-path>/login/login</struts-action-path> 
        <struts-action-impl> 
        com.myhook.action.ExampleStrutsPortletAction 
        </struts-action-impl> 
    </struts-action> 
    
  2. BaseStrutsPortletActionを拡張したStrutsポートレットアクションクラスを作成します。struts-action要素インサイド

  3. 、あなたがオーバーライドしているアクションのパスを指定しstruts-action-pathとカスタムアクションclass.Thisを指定struts-action-implを追加するようになります。このクラスの例は次のとおりです。

    オーバーライドされるメソッドを呼び出す
    public class ExampleStrutsPortletAction extends BaseStrutsPortletAction { 
    
         public void processAction(StrutsPortletAction originalStrutsPortletAction, 
           PortletConfig portletConfig, ActionRequest actionRequest, 
           ActionResponse actionResponse) throws Exception { 
    
          System.out.println("Custom Struts Action"); 
    
          originalStrutsPortletAction.processAction(originalStrutsPortletAction, 
            portletConfig, actionRequest, actionResponse); 
         } 
    
        public String render(StrutsPortletAction originalStrutsPortletAction, 
          PortletConfig portletConfig, RenderRequest renderRequest, 
          RenderResponse renderResponse) throws Exception { 
    
         System.out.println("Custom Struts Action"); 
    
         return originalStrutsPortletAction.render(null, portletConfig, 
           renderRequest, renderResponse); 
        } 
    } 
    

    originalStrutsPortletAction.processActionのように、義務が、Liferayのポータルの点で変わらない行動から行動を維持するためのベストプラクティスではありません。

    <struts-action> 
        <struts-action-path>/my/custom/path</struts-action-path> 
        <struts-action-impl> 
        com.myhook.action.ExampleStrutsAction 
        </struts-action-impl> 
    </struts-action> 
    
1

あなたがLiferayのPortalDelegateServletでサーブレットをラップする必要があります。 フックのこのタイプはまた、新たなStrutsのアクションを追加するために使用することができ、この場合にはliferay-hook.xmlは次のようになり、既存のアクションを変更するのと同じです - Usage of PortalDelegateServlet in Liferay

関連する問題