AJAX support for markup

JBoss Portal Server Development

Chapter 6
Portals and AJAX

This chapter excerpt from JBoss Portal Server Development by Ramanujam Rao, is printed with permission from Packt Publishing, Copyright 2007.

NEXT>>

AJAX support for markup

JBoss portal supports markup through tags on layouts and renderers of the pages. Special tags are added to layout JSPs that facilitate the placement of AJAX features on a page. Similarly, renderers are used to interpret the tags and to render AJAX-driven content. The obvious advantage is the in-built support for the auto-creation and control of AJAX components on portal pages.

Layout markup

As discussed earlier, layouts provide a structure for the creation and serving of portal pages. Layouts aggregate all of the content generated by the portlet, based on region and order, merge them with some additional content provided by the portal, and serve a response back to the user. By providing support for AJAX in the layout, helps facilitate the easy development and implementation of dynamic functionality in pages, with minimal effort.

Layout markup is implemented using JSP tags. The JBoss JSP tag library, portlet-layout.tld, offers tags that facilitate the implementation of AJAX features in layouts. A JSP layout can be changed to an AJAX-supported page simply by adding references to the tags. Hence, using tags also helps with the easy implementation of features.

The following is the layout page from the default portal generic layout ${JBOSS_ PORTAL_HOME}\server\default\deploy\jboss-portal.sar\portal-core.war\ layouts\generic\index.jsp, and shows AJAX support implemented as tags:

<%@ page import="org.jboss.portal.server.PortalConstants" %>
<%@ taglib uri="/WEB-INF/theme/portal-layout.tld" prefix="p" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%= PortalConstants.VERSION.toString() %></title>
<meta http-equiv="Content-Type" content="text/html;"/>
<!-- to correct the unsightly Flash of Unstyled Content. -->

<script type="text/javascript"></script>
<!-- inject the theme, default to the Renaissance theme if nothing is selected for the portal or the page -->
<p:theme themeName="renaissance"/>
<!-- insert header content that was possibly set by portlets on the page -->
<p:headerContent/>
<%@include file="/layouts/common/modal_head.jsp"%>
</head>
<body id="body">
<p:region regionName='AJAXScripts' regionID='AJAXScripts'/>
<%@include file="/layouts/common/modal_body.jsp"%>
</head>
<body id="body">
<p:region regionName='AJAXScripts' regionID='AJAXScripts'/>
<%@include file="/layouts/common/modal_body.jsp"%>
<div id="portal-container">
<div id="sizer">
<div id="expander">
<div id="logoName"></div>
<table border="0" cellpadding="0" cellspacing="0" id="header-container">
<tr>
<td align="center" valign="top" id="header">
<!-- Utility controls -->
<p:region regionName= 'dashboardnav' regionID= 'dashboardnav'/>
<!-- navigation tabs and such -->
<p:region regionName= 'navigation' regionID='navigation'/>
<div id="spacer"></div>
</td>
</tr>
</table>
<div id="content-container">
<!-- insert the content of the 'left' region of the page, and assign the css selector id 'regionA' -->
<p:region regionName='left' regionID='regionA'/>
<!-- insert the content of the 'center' region of the page, and assign the css selector id 'regionB' -->
<p:region regionName='center' regionID='regionB'/>
<hr class="cleaner"/>
</div>
</div>
</div>
</div>
<div id="footer-container" class="portal-copyright">Powered by
<a class="portal-copyright" href="http://www.jboss.com/products/ jbossportal">JBoss Portal</a><br/>
</div>
<p:region regionName='AJAXFooter' regionID='AJAXFooter'/>
</body>
</html>

Renderer markup

The portal combines the renderers and layouts to generate the fi nal content. Enabling support for AJAX in the renderer just requires adding the statement
<ajax-enabled>true</ajax-enabled> to the renderer descriptor.

The following example, at {JBOSS_PORTAL_HOME}\server\default\deploy\jbossportal. sar\portal-core.war\WEB-INF\layout\portal-renderSet.xml, shows the renderer confi guration of the emptyRenderer RenderSet for AJAX support:

<renderSet name="emptyRenderer">
<set content-type="text/html">
<ajax-enabled>true</ajax-enabled>
<region-renderer>
org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer
</region-renderer>
<window-renderer>
org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer
</window-renderer>
<portlet-renderer>
org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer
</portlet-renderer>
<decoration-renderer>
org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer
</decoration-renderer>
</set>
</renderSet> 

NEXT>>

Also read

Portal and Portlet interview

What is a Portlet? Explain its capabilities.
Explain Portal architecture.
What is PortletSession interface?
What is PortletContext interface?
Why portals?................... 



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring