nextwebgen.com

The Next Generation Web Now

Ajax Portlet Communication with DWR

Filed under: Web 2.0 News, Front Page, Articles, Portal — Dion Almaer at 11:21 am on Friday, July 14, 2006

Sami Salkosuo has added fuel to the fire of the claims that "Ajax is perfect for portals and portlets, and we can finally do them right" with his piece DWR makes interportlet messaging with Ajax easy:

Many developers are looking to use Ajax technologies to improve the user experience of Web-based applications, but Ajax programming can be a tricky task. The open source Direct Web Remoting (DWR) library can make Ajax development easier for Java™ developers by automatically transforming Java classes into JavaScript classes. In this article, you'll learn how how to use DWR and JSR-168-compliant portlets to build an Ajax application quickly and easily.

The article has a lot of code to show by example, how this all works, most of it Java, with a touch of JSP:

<%@ page contentType="text/html"
import="java.util.*,javax.portlet.*,interportletmessagingusingajax.*" %>

<%@taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet :defineObjects/>

<script type="text/javascript"
        src='<%= renderResponse.encodeURL(renderRequest.getContextPath() +
        "/dwr/interface/MessagingBean.js") %>
'>
</script>

<script type="text/javascript"
        src='
<%= renderResponse.encodeURL(renderRequest.getContextPath() +
        "/dwr/engine.js") %>'>
</script>

<script type="text/javascript">

function <portlet :namespace />sendOrderNr(orderNr)
{
document.getElementById("orderDetailsOrderNumber").innerHTML=orderNr;
document.getElementById("customerDetailsOrderNumber").innerHTML=orderNr;
MessagingBean.getOrderDetails(orderNr,<portlet :namespace />showOrderDetails);
MessagingBean.getCustomerDetails(orderNr,<portlet :namespace />showCustomerDetails);

return false;
}

function <portlet :namespace />showOrderDetails(orderDetails)
{
document.getElementById("orderDetails").innerHTML=orderDetails;
return false;
}

function <portlet :namespace />showCustomerDetails(customerDetails)
{
document.getElementById("customerDetails").innerHTML=customerDetails;
return false;
}
</script>
 

Spotback: Personalized Portal

Filed under: Web 2.0 News, Front Page, Showcase, Portal — Dion Almaer at 1:41 pm on Thursday, July 13, 2006

Spotback is a new portal that lets you get very personal with new interest Ajax features.

Once you hit the site you can start to rate stories via slider instead of typical star ratings (I personally feel like stars are more usable as you don’t need to drag you can just click). As you rate items highly, new content “like that” will appear for you.

Other nicely done features are:

  • Drop down categories
  • Simple links to other people who like the content
  • The “more…” link opens content up inline
  • Simple settings for turning on and off animation, tooltips, high grade bringing in the new story etc

Quite nice really!

Spotback