java - 如何在 liferay 中构建特定条件的 portlet

标签 java javascript google-maps jsp liferay

我们的团队构建了一个自定义 portlet,用于将 Google 标记加载到 map 上。标记是在模板脚本中创建的。我们现在希望以类似列表的格式在另一个 Assets 发布者中显示这些标记。无论如何,是否可以根据请求它的 portlet 将条件传递给模板文件?或者是否有任何好的方法可以将此代码构建到 jsp 而不是模板文件中?

//code that creates the markers on the full map
gmarker=new google.maps.Marker({position:new google.maps.LatLng("$Lattitude.getData()","$Longitude.getData()"),title:"$reserved-article-title.getData()",icon:gicon,map:map});
if(window.location.href.indexOf("fullmap") > -1) {
     google.maps.event.addListener(gmarker, 'click', function() {
         new google.maps.InfoWindow({content:
           '<div id="node_content">
               <div id="siteNotice"></div>
               <h3 id="firstHeading" class="firstHeading">$reserved-article-title.getData(), $City.getData(), $Country.getData()</h3>
               <hr class="m_spacer"/>
               <div id="bodyContent">
                  <p class="gdes">$Description.getData()</p>
                  <img class="m_image" src="$Image.getData()"/>
               </div>
             </div>'
         }).open(map,this);
     });
 }
gmarker.setMap(map);
//redirect code that opens the infowindow on load if the id paramater is not null
if(flag==true){new google.maps.InfoWindow({content:
   '<div id="node_content" class="gs2">
         <div id="siteNotice"></div>
         <h3 id="firstHeading" class="firstHeading">$reserved-article-title.getData(), $City.getData(), $Country.getData()</h3>
         <hr class="m_spacer"/>
         <div id="bodyContent">
            <p class="gdes">$Description.getData()</p>
            <img class="m_image" src="$Image.getData()"/>
         </div>
    </div>'}).open(map,gmarker);
    flag=false;
}

现在是 liferay 6.1,所以我们无法享受最新版本的奢华。 Here是两个 portlet 及其显示内容的屏幕截图,以及我们目标的示例。可以找到与我们正在尝试的非常相似的网站 here 。我们希望获得关于如何区分 portlet 的概念性想法,而不是代码。非常感激你的帮助。

最佳答案

如果您想在不同的 portlet 中使用相同的 JavaScript 函数,那么更好的方法是将 JavaScript 函数放入主题

http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/creating-themes-and-layout-templates-liferay-portal-6-2-dev-guide-09-en

并从具有不同属性的 portlet-jsp 调用该函数。

关于java - 如何在 liferay 中构建特定条件的 portlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21024214/

相关文章:

Java 方法调用问题,从新的 .java 类返回主菜单,可能存在数组问题

java - 为 API 定义自定义错误代码的最佳实践

java - 套接字是否可以在没有端口转发的情况下连接到 SeverSocket(0)?

javascript - React.js 使用非状态变量时出现错误,因为组件正在更改要控制的文本类型的不受控制的输入

java - 在android中查找触摸事件之间的持续时间

javascript - 在谷歌地图中正确定位邮政编码标签

android - 在 android 的谷歌地图上突出显示一条街道

ios - 如何获得 MKPolyline 上的等距位置?

iphone - 将图 block 坐标转换为像素再转换为地理坐标

javascript - jquery ajax 没有完成