2015-11-30 64 views
0

我想在liferay上動態加載頁面。現在我必須用jsp的renderURL和DIV:Liferay動態jsp加載jQuery

<div id="sub_content2"></div> 

<portlet:renderURL var="displayOtherDocumentURL1"> 
<portlet:param name="action" value="displayOtherDocument" /> 
<portlet:param name="activeTab" value="2" /> 
<portlet:param name="activeVerticalTab" value="6" /> 
</portlet:renderURL> 

<aui:script> 
$(document).ready(function() { 
    //alert('1231'); 
    //$("#sub_content").load("displayEditSchoolEducation"); 
    //alert('11'); 
    $("#sub_conten2").load("${displayOtherDocumentURL1}"); 
     alert('aaa'); 
}) 

而在控制器我有這樣的方法:

@RenderMapping(params = "action=displayOtherDocument") 
public String displayOtherDocument(final RenderRequest request, final RenderResponse response, 
     final ModelMap modelMap) throws PortalException, SystemException {} 

通常一切工作。但是,動態加載不:(救命啊!援助組織!娜pomoc!

回答

0

爲了在Ajax加載,你應該創建一個ResourceMapping不是RenderMapping。

+0

不過does't工作:(我在幾個小時前就厭倦了它,問題是,liferay並沒有叫做spring req uerst /資源映射,我不知道爲什麼:( –

+0

你能告訴我們你使用ResourceMapping製作的代碼嗎? – fabballe

+0

我已經修好了;) –

0

在我看來,你缺少的JSP

的名字
<portlet:renderURL var="displayOtherDocumentURL1"> 
    <portlet:param name="jspPage" value="/jsp/new_page.jsp"/> 
</portlet:renderURL> 

然後

$("#sub_conten2").load("${displayOtherDocumentURL1}"); 

應該工作。如果你想使用的資源,而不是這是有道理的,如果你沒有做任何JSP預過程,那麼你必須打開日e文件併發送整個文件。

0

我找到了一個解決方案:

<portlet:resourceURL var="displayOtherDocumentURL" id="displayOtherDocument"></portlet:resourceURL> 

-

$("#displayOtherDocumentDIV").load("${displayOtherDocumentURL}"); 

-

@ResourceMapping(value = "displayOtherDocument") 
    public ModelAndView displayOtherDocument(final ResourceRequest request) throws PortalException, SystemException { 

     final ModelAndView modelAndView = new ModelAndView("components/otherDocumentForm", model); 
     return modelAndView; 
    } 

容易,而且工作;)