Saturday 17 March 2012

Working with portlet container in websphere application server 7.0-Part6

In this example, MyPortletAggregator application context path is :myportletaggregator.

The page has two portlet- My portlet and MyPortletPref.

Sample Code

portal.jsp

<%@ taglib uri="http://ibm.com/portlet/aggregation" prefix="portlet" %>
<%@ page isELIgnored ="false"%>

<portlet:init portletURLPrefix="/myportletaggregator/portal/">

<!-- create portal table of two columns -->
<TABLE BORDER="5">
 <TR BGCOLOR="BBBBFF">
  <TD>
   <!-- insert portlet title bar into left column -->
   <TABLE WIDTH="100%">
     <TR>
        <TD>
          <B><span id="title_1">Portlet 1</span></B>
        </TD>
        <TD ALIGN="right">
        <a href="<portlet:state url='myportlet/MyPortlet' windowId='stephan' portletMode='view'/>">view</a>
        </TD>
     </TR>
   </TABLE>
  </TD>
  <TD>
   <!-- insert portlet title bar into right column -->
   <TABLE WIDTH="100%">
     <TR>
        <TD>
          <B><span id="title_2">Portlet 2</span></B>
        </TD>
        <TD ALIGN="right">
             <a href="<portlet:state url='myportletpref/MyPortletPref' windowId='birga' portletMode='view'/>">view</a>
        </TD>
     </TR>
   </TABLE>
  </TD>
 </TR>
 <TR>
  <TD>
<!-- insert portlet into left column -->
   <portlet:insert url="myportlet/MyPortlet" windowId="stephan" titleVar="portlettitle_1"/>
  </TD>
  <TD>
<!-- insert portlet into right column -->
    <portlet:insert url="myportletpref/MyPortletPref" windowId="birga" titleVar="portlettitle_2"/>
  </TD>
 </TR>
</TABLE>

<!-- insert portlet title -->
<script type="text/javascript">
  document.getElementById("title_1").firstChild.nodeValue = '${portlettitle_1}';
  document.getElementById("title_2").firstChild.nodeValue = '${portlettitle_2}';
</script>

</portlet:init>


ScreenShot


Click here to download the sample code

Note : MyPortlet (context path:myportlet ) and MyPortletPref(context path:myportletpref) Application needs to be deployed.

No comments:

Post a Comment