Modular Page Assembly in Rails (Part 2)

In Part 1, I explained how you can develop clean, DRY and encapsulated MVC code that allows for completely modular page assembly in Ruby on Rails.

In this follow up post, I explain how you can use a combination of layouts and content_for to apply title bars and consistent styles to your page components (or modules or portlets, or whatever you want to call them).

The code here is easy to follow and it pretty much speaks for itself. It consists of two layouts (which I called aggregate and snippet), a sample controller and two sample views. Let’s start with the controller for one page in your site that, say, aggregates a couple of modular page components together to show a nice view of company information.

Controller code (app/controllers/company_controller.rb):

def index
  render :action => 'index', :layout => 'aggregate'  
end

This controller simply delegates the rendering of the page to the index.html.erb view and tells Rails to use a layout called aggregate.

Now let’s inspect the view.

View code (app/views/company/index.html.erb):

<% content_for :left do %>
 <%= embed_action :controller => 'company', :action => 'company_list' %>
 <%= embed_action :controller => 'feed', :action => 'feed' %>
<% end %>

<% content_for :center do %>
 <%= embed_action :controller => 'company', :action => 'detail' %>
<% end %>

<% content_for :right do %>
 <%= embed_action :controller => 'home', :action => 'sponsors' %>
<% end %>

This view defines three content regions, with the end goal being to create a page with three columns of “portlets.” The left column contains two portlets: a list of all companies (company_list) and a news feed (feed). The center column contains a company detail portlet and the right column contains a portlet with information about sponsors. (Note that the portlets come from three different functional areas of the site, so they’re decomp’d appropriately into three different controllers.)

Now, let’s take a look at some layout magic.

Here’s the aggregate layout (app/views/layouts/aggregate.html.erb):

<table class="main" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td id="column-left" class="column" valign="top">
        <div id="region-left" class="region"><%= yield :left %></div>
      </td>
      <td id="column-center" class="column" valign="top">
        <div id="region-center" class="region"><%= yield :center %></div>    
      </td>
      <td id="column-right" class="column" valign="top">
        <div id="region-right" class="region"><%= yield :right %></div>
      </td>
    </tr>
  </tbody>
</table>

I chose a table (yes, I still use tables) with three divs in it, one for each region of modules, but you could use pure divs with floating layouts or any other approach.

The three content regions, left, center and right, match up with the three content sections defined in the index view above using content_for. In case this isn’t obvious, when the layout encounters a page-level definition of a content region in the view, it renders it. If there is no definition for a particular region, the containing column will just collapse on itself, which is the behavior we want.

This is a slight digression, but note how I used CSS classes to identify the columns and regions in a general way (using classes) and a specific way (using ids). This allows me to style the whole module-carrying region with CSS using table.main as my selector, all the columns using table.main td.column as my selector or all the regions using table.main td.column div.region as my selector. I can also pick and choose different specifc areas (e.g. table.main td.column#column-right) and define their style attributes using CSS. As you’ll see in a minute, I can write CSS selectors to say if module A is in the left column, apply style X but if module A is in the center or right column, apply style Y. Pretty cool.

Now, let’s explore the module layout. (Note that I’ve been calling page snippets portlets, modules or components, pretty much interchangeably. I think this illustrates that it doesn’t make a difference what we call ’em — e.g. portlets vs. gadgets — the concept is fundamentally clear and fundamentally the same.)

Module layout (app/views/layouts/snippet.html.erb):

<div id="<%= yield :id %>"><%= yield :id %>" class="snippet-container">
  <div class="snippet-title"><%= yield :title %></div>
  <div class="snippet-body"><%= yield :body %></div>
</div>

This layout expects three more content regions to be defined in the view: id, title and body. Here are the matching content regions from one sample view (for sponsors) — for brevity’s sake, I didn’t include all the views.

Sample module view (app/views/home/sponsors.html.erb):

<% content_for :id do %>sponsors<% end %>

<% content_for :title do %>Our Sponsors<% end %> 

<% content_for :body do %>
Please visit the sites of our wonderful sponsors!
<% end %>

Now, because of some nicely-placed classes and ids, I can once again use CSS selectors to give a common look-and-feel to all portlet containers (div.snippet-container), portlet titles (div.snippet-title) and to portlet bodies (div.snippet-body). Of course, if I want to diverge from the main look-and-feel, I can call out specific portlets: div.snippet-body#sponsors.

If I really want to get fancy, I can use CSS selectors to select, say, the sponsor portlet, but only when it’s running in the right column: table.main td.column-right div.snippet-container#sponsors.

So, in summary, using layouts, content_for and some crafty CSS, I can create a page of modules that can be styled generically or specifically. Combine this approach with what I described in Part 1, and you can “portal-ize” your Rails applications without using a portal!

Was this useful to you? If so, please leave a comment.

The Social Collective Debuts at RubyNation

We’re very pleased to announce that, together with the organizers of RubyNation, we debuted our social application “The Social Collective” today as a means for RubyNation conference attendees and other Rubyists to meet and interact with their peers.

This is a very similar codebase to what we deployed at BEA Participate in May, but without ALI or ALBPM. These BEA (now Oracle) products provided a great, scalable and flexible architecture, but we didn’t feel it was a good use of our resources (i.e. $$$s) to continue to use these products and we didn’t want to pass this cost on to RubyNation, which, BTW, is only charging $175 for two jam-packed days of Ruby awesomeness.

So, for those of you who have been following all this social goodness coming from bdg, there are now two distinct versions of The Social Collective: one that uses BEA/Oracle products and one that does not. This affects pricing (obviously), so if you’re interested in either, please contact us to find out more.

And in the meantime, if you’re as gung ho about Ruby as we are, sign up for an account and help us grow the Ruby community here in DC and beyond!

Modular Page Assembly in Rails (Part 1)

Recently I was faced with an interesting problem: I wanted to create a modular, portal-like page layout natively in Ruby on Rails without using another layer in the architecture like SiteMesh or ALUI. Java has some pretty mature frameworks for this, like Tapestry, but I found the Ruby on Rails world to be severely lacking in this arena.

I started with Rails 2.0 and the best I could come up with at first brush was to create a html.erb page comprised of several partials. Each partial would basically resemble a “portlet.” This works fine, but with one showstopping pitfall — you can’t call controller logic when you call render :partial. That means in order for each page component (or portlet, if you like) to maintain its modularity, you would have to either 1) put all the logic in the partial view (which violates MVC) or 2) repeat all the logic for each component in the controller for every page (which violates DRY).

If that’s not sinking in, let me illustrate with an example. Let’s say you have two modular compontents. One displays the word “foo” and the other “bar”, which are each contained in page-level variables @foo and @bar, respectively. You want to layout a page containing both the “foo” and the “bar” portlets, so you make two partials.

“foo” partial (app/views/test/_foo.html.erb):

<%[email protected]%>

“bar” partial (app/views/test/_bar.html.erb):

<%[email protected]%>

Now, you make an aggregate page to pull the two partials together.

aggregate page (app/views/test/aggregate.html.erb):

<%=render :partial => 'foo' %>
<%=render :partial => 'bar' %>

You want the resulting output to say “foo bar” but of course it will just throw an error unless you either embed the logic in the view (anti-MVC) or supply some controller logic (anti-DRY):

embedded logic in the view (app/views/test/_foo.html.erb):

<%@foo = 'foo'%>
<%[email protected]%>

embedded logic in the view (app/views/test/_bar.html.erb):

<%@bar = 'bar'%>
<%[email protected]%>

— OR —

controller logic (app/controllers/test_controller.rb):

def aggregate
 @foo = 'foo'
 @bar = 'bar'
end

Neither solution is optimal. Obviously, in this simple example, it doesn’t look too bad. But if you have hundreds of lines of controller logic, you certainly don’t want to dump that in the partial. At the same time, you don’t want to repeat it in every controller that calls the partial — this is supposed to be modular, right?

What a calamity.

I did some research on this and even read a ten-page whitepaper that left me with no viable solution, but my research did confirm that lots of other people were experiencing the same problem.

So, back to the drawing board. What I needed was a way to completely modularize each partial along with its controller logic, so that it could be reused in the context of any aggregate page without violating MVC or DRY. Enter the embed_action plugin.

This plugin simply allows you to call invoke a modular bit of code in a controller and render its view, but not in a vacuum like render :partial. With it, I could easily put controller logic where it belongs and be guaranteed that no matter where I invoked the “portlet,” it would always render correctly.

Here’s the “foo bar” example, implemented with embed_action.

“foo” controller (app/controllers/foo_controller.rb):

def _foo
 @foo = 'foo' #this logic belongs here
end

“bar” controller (app/controllers/bar_controller.rb):

def _bar
 @bar = 'bar' #this logic belongs here
end

aggregate view (app/views/test/aggregate.html.erb):

<%= embed_action :controller => 'foo', :action => '_foo' %>
<%= embed_action :controller => 'bar', :action => '_bar' %>

That’s it! Note that there is no logic in the aggregate controller — that’s not where it belongs. Instead, the foo and bar logic has been modularized/encapsulated in the foo and bar controllers, respectively, where the logic does belong. Now you can reuse the foo and bar partials anywhere, because they’re 100% modular.

Thanks to embed_action, I was finally able to create a completely modular page (and site) design, with very little effort on my part.

In a follow-up post (Part 2), I’ll explain how you can create really nice-looking portlets using everything above plus layouts and content_for.

This Just In — BEA Participate Social App Stats

I find this a little hard to believe, but the numbers don’t lie. We had a whopping 75,000 page views the week of the conference!

That’s more than 100 page views per registered attendee. This chart was from our hottest day, Tuesday, 5/13.

5-13-08(3)Thanks to everyone for using our application. I think we may be on to something here!

Write an ALUI IDS in Under 15 Lines Using Ruby on Rails

Not only is it possible to write an ALUI Identity Service in Ruby on Rails, it’s remarkably easy. I was able to do the entire authentication part in fewer than 15 lines of code! However, I ran into problems on the synchronization side and ended up writing that part in Java. Read on for all the gory details.

As part of building the suite of social applications for BEA Participate 2008, we’re designing a social application framework in Ruby on Rails and integrating it with ALI 6.5. Not being a big fan of LDAP, I decided to put the users of the social application framework in the database (which is MySQL). Now, when we integrate with ALI, we need to sync this user repository (just as many enterprises do with Active Directory or LDAP).

So I set out to build an IDS to pull in users, groups and memberships in Ruby on Rails.

It’s pretty obvious that Ruby on Rails favors REST over SOAP for their web service support. However, they still support SOAP for interoperability and it mostly works. I did have to make one patch to Ruby’s core XML processing libraries to get things humming along. I haven’t submitted the patch back to Ruby yet, but at some point I will. Basically, the problem was that the parser didn’t recognize the UTF-8 encoding if it was enclosed in quotes (“UTF-8”). This patch suggestion guided me in the right direction, but I ended up doing something a little different because the suggested patch didn’t work.

I changed line 27 of lib/ruby/1.8/rexml/encoding.rb as follows:

 enc = enc.nil? ? nil : enc.upcase.gsub('"','') #that's a double quote inside single quotes

Now that Ruby’s XML parser recognized UTF-8 as a valid format, it decided that it didn’t support UTF-8! To work around this, I installed iconv, which is available for Windows and *nix and works seamlessly with Ruby. In fact, after installation, all the XML parsing issues went bye-bye.

Now, on to the IDS code. From your rails project, type:

ruby script/generate web_service Authenticate

This creates app/apis/authenticate_api.rb. In that file, place the following lines of code:

class AuthenticateApi < ActionWebService::API::Base
 api_method :Authenticate, :expects => [{:Username =>
:string}, {:Password =>
:string}, {:NameValuePairs =>
[:string]}], :returns =>
[:string]
end

All you’re doing here is extending ActionWebService and declaring the input/output params for your web service. Now type the following command:

ruby script/generate controller Authenticate

This creates the controller, where, if you stick with direct dispatching (which I recommend), you’ll be doing all the heavy lifting. (And there isn’t much.) This file should contain the following:

class AuthenticateController < ApplicationController
 web_service_dispatching_mode :direct
 wsdl_service_name 'Authenticate'
 web_service_scaffold :invoke

 def Authenticate(username, password, nameValuePairs)
   if User.authenticate(username, password)
     return ""
   else
     raise "-102" #generic username/password failure code
   end
 end
end

Replace User.authenticate with whatever mechanism you’re using to authenticate your users. (I’m using the login_generator gem.) That’s all there is to it! Just point your AWS to http://localhost:3000/authenticate/api and you’re off to the races.

Now, if you want to do some functional testing (independently of the portal), rails sets up a nice web service scaffold UI to let you invoke your web service and examine the result. Just visit http://localhost:3000/authenticate/invoke to see all of that tasty goodness.

There you have it — a Ruby on Rails-based IDS for ALUI in fewer than 15 lines of code!

The synchronization side of the IDS was almost just as simple to write, but after countless hours of debugging, I gave up on it and re-wrote it in Java using the supported ALUI IDK. Although I never could quite put my finger on it, it seemed the problem had something to do with some subtleties about how BEA’s XML parser was handing UTF-8 newlines. I’ll post the code here just in case anyone has an interest in trying to get it to work. Caveat: this code is untested and currently it fails on the call to GetGroups because of the aforementioned problems.

In app/apis/synchronize_api.rb:

class SynchronizeApi < ActionWebService::API::Base
 api_method :Initialize, :expects =>
[{:NameValuePairs =>
[:string]}], :returns =>
[:integer]
 api_method :GetGroups, :returns =>
[[:string]]
 api_method :GetUsers, :returns =>
[[:string]]
 api_method :GetMembers, :expects =>
[{:GroupID => :string}], :returns =>
[[:string]]
 api_method :Shutdown
end

In app/controllers/synchronize_controller.rb:

class SynchronizeController < ApplicationController
  web_service_dispatching_mode :direct
  wsdl_service_name 'Synchronize'
  web_service_scaffold :invoke

  def Initialize(nameValuePairs)
    session['initialized'] = true
    return 2
  end

  def GetGroups()
    if session['initialized']
      session['initialized'] = false
      groups = Group.find_all
      
      groupNames = Array.new
      for group in groups
        groupNames << "<SecureObject Name=\"#{group.name}\" AuthName=\"#{group.name}\" UniqueName=\"#{group.id}\"/>" 
      end 
      return groupNames
    else
      return nil
    end
  end
  
  def GetUsers()
    if session['initialized']
      session['initialized'] = false
      users = User.find_all
      
      userNames = Array.new
      for user in users
        userNames << "<SecureObject Name=\"#{user.login}\" AuthName=\"#{user.login}\" UniqueName=\"#{user.id}\"/>" 
      end
      
      return userNames
    else
      return nil
    end
  end

  def Shutdown()
    return nil
  end
end

Comments

Comments are listed in date ascending order (oldest first)

  • Nice post, Chris. This is the first time I’ve seen this done!

    Posted by: dmeyer on January 20, 2008 at 4:16 PM

  • Thank you, David.I just noticed that part of my sync code was chomped off in the blog post because WordPress was assuming that was actually an opening HTML/XML tag. I made the correction so the above code now accurately reflects what I was testing.

    Posted by: bucchere on January 21, 2008 at 1:16 PM

One Portal to Rule Them All

I won’t rehash what’s already been said by everyone in the press and the blogosphere — Oracle is buying BEA. I wrote almost three years ago that this was inevitable, and now it’s upon us.

I’m hopeful that the BEA/Oracle management crew can take what they learned from the Plumtree, Fuego and Flashline (for BEA) and Siebel, PeopleSoft and Oblix (for Oracle) acquisitions and apply it to the challenges their own merger presents.

Over the past three years, Oracle has acquired dozens of companies. The most notable were probably PeopleSoft (which had just acquired JD Edwards, if I remember correctly), Siebel and Oblix, which gave them a great suite of HR apps, CRM apps and identity management, respectively. These were all enterprise software products that Oracle had, with a modicum of success, built on their own from the ground up, sold and supported as “Oracle Apps.”

Of course, with almost every major company they’ve acquired, Oracle has picked up a portal product. (And with BEA, there’s a special bonus — they get two: WLP and ALI.)

That’s going to create a portal soup consisting of at least the following ingredients:

  • Siebel Portal
  • JD Edwards Portal
  • PeopleSoft Portal
  • Oracle Portal (part of Oracle Fusion Middleware)
  • WLP
  • ALI

Oracle won’t want to endanger existing customer relationships by terminating support for the non-horizontal portals from Siebel, PeopleSoft, etc. Besides, the word “portal” really only loosely applies there, because those “portals” are really just web UIs into Siebel, PeopleSoft, etc.

But what about the horizontal portals: Oracle, WLP and ALI?

They are all playing in the same space. It’s already questionable that we need all three in the market now. And three under the same circle-shaped roof that is Oracle? Absurd.

What will Oracle do with this portal quandary?

Well, I think they’ll do the only thing they can do and support all the products. So that covers legacy customers, but what about future customers? If I’m an Oracle sales rep and my customer wants to buy a portal to front their SOA stack, what on earth do I sell them?

In my opinion, which is just that — my opinion — post-merger, there need to be some decisive acts from Oracle regarding the future direction of their portal strategy.

And, again, IMO, this is where the ALI portal and the ALUI suite of products (formerly Plumtree) can really shine. Why? Because not only can you front Java, .NET, Rails, PHP and any other web application stack with ALI, but ALI already has integration kits for Siebel, PeopleSoft, JSR-168, WSRP and five different flavors of SSO, including Oblix! (Not to mention the obvious fact that since day one, ALI has run beautifully on Windows and *nix systems using Oracle’s bread-and-butter product, their database.) So naturally, if you’re an Oracle shop running a clustered Oracle DB for storage, Siebel for CRM, PeopelSoft for HR, Oracle Financials for the books and Oblix Identity Management, no other product under the sun has more pre-packaged, no-brainer integration and integration options than ALI.

It may be a hard, bloody battle to get Oracle to drop it’s own beloved portal product in favor of AquaLogic Interaction, but I think it’s a battle that needs to be fought.

Same goes for WLP. In fact, I think every product acquired by Oracle has to fight for it’s life and fight to be the #1 product in the space, retiring the others to “maintenance and support” but focusing all futures on the product that is rightfully #1. And I think — and hope — that Oracle has the good sense and the wherewithal to encourage this.

It may cause some near term pain, but taking a longer-term view it’s the right thing to do.

Comments

Comments are listed in date ascending order (oldest first)

  • Interesting post, Chris. Obviously this is something we ALUI consultants have been considering in the past few days. One monkeywrench I have for you: as far as I know, Oracle offers their portal product for free to existing customers, whereas we (obviously) charge for it. I wonder how that kind of business model might change the landscape of how the ALUI portal is distributed/used.

    Posted by: rbrodbec on January 18, 2008 at 7:02 AM

  • Funny you should mention the price issue. About two years ago, we had a customer switch from ALI to Oracle portal for that exact reason. Why pay for licenses and support for ALUI products when Oracle gives you the portal for free? That customer still calls on us for ALUI support, so apparently the migration hasn’t gone exactly as planned.Two old adages come to mind here:
    1. You get what you pay for.
    2. There’s no such thing as a free lunch.

    Regarding #1, the products really don’t cover the same feature set — Oracle portal cannot be the gateway to SOA that we all know ALUI is, so it’s really not an apples-to-apples comparison.

    Regarding #2, with any free software, whether it’s from a large company like Oracle or from the Apache Software Foundation, you always need to think about Total Cost of Ownership (TCO). If you need to build services integration points in Oracle Portal to talk to all of Oracle’s other products, that adds to your TCO. Moreover, if somebody is giving something away, what sort of quality expectations do you have about the product? What happens if you need to request support from Oracle or ask them to develop a patch for you? All of a sudden, the fact that you didn’t pay for the software comes back and bites you in the butt. 🙂

    Posted by: bucchere on January 18, 2008 at 7:23 AM

  • I guess I agree with you, since I’m not an Oracle portal consultant (not yet, anyway); but I think the bigger question is how Oracle will assimilate these new portals given its current pricing strategy (aka – the bloody war you speak of). If I were an existing Oracle customer, the first question I’d ask is “how come I can get XYZ portal for free but not ABC portal”. And if I’m Oracle product management, I’m thinking about how my current “free portal” strategy has been working out for me versus the ALUI model of charging for it.

    Posted by: rbrodbec on January 18, 2008 at 8:22 AM

  • You’re right — the big issue is how will Oracle deal with the portals they’re acquiring and will there be a shakedown or more of a graceful assimilation.There’s a similar issue with WLS and Oracle’s application server, although I think in that case the answer is a little less complicated. 😉

    Posted by: bucchere on January 18, 2008 at 8:32 AM

  • Of course you completely forgot to mention Oracle WebCenter. In spite of your assertions, there are only 2 portal products at Oracle. Oracle Portal and WebCenter. WebCenter is the future “face” of Fusion Applications, so any integration of portal products will move in that direction. IMHO….plumtree is as proprietary as Oracle Portal, and its dead. WLP and the folks on the WebCenter team will need to figure out how to integrate the code bases of those two products since they are the most similar in their support of Web 2.0 futures.

    Posted by: Dr. BEA Good on January 20, 2008 at 11:44 AM

  • Thanks for the correction about Oracle WebCenter — I’m not too familiar with Oracle products other than the DB and I should have done more homework before posting this!However, I still disagree that there are only two portals at Oracle. I’m not too sure about JDE, but I remember with 100% certainty that PeopleSoft and Siebel called their UIs “portals.” They’re not truly portals in a horizontal sense like Oracle Portal, WebCenter, WLP and ALUI and I don’t think they’re actually relevant to this discussion, so it’s a moot point.

    Now, given the four remaining portal products, I challenge your assertion that WebCenter and WLP “support Web 2.0 futures” and I’d like to see some examples that support that claim. As far as I know, the only products coming out of BEA that deserve the “Web 2.0” label are AquaLogic Pages, Ensemble and Pathways. (Note I don’t include ALI itself as a Web 2.0 product, despite the fact that ALI 6.5 has some pretty slick social features that might someday earn it that distinction.)

    I also take issue with your calling Plumtree/ALUI proprietary and I’m not sure what makes you make that claim. It’s written in Java and ported to C#.net, so it runs “natively” on IIS (which no other products from BEA or Oracle can do). Its Java version (from the same source base), runs on WebSphere, WLS, Tomcat and probably JBoss and other app servers and it supports both Oracle and SQL Server, so in terms of how and where you can run it, it’s probably the most open and flexible product in the entire 40+ product lineup that BEA boasts.

    That’s just one side of the proprietary vs. open argument. The other is how well one supports standards for plugging in functionality. In those terms, I think ALUI stands out from the pack as well. It supports portlets over two very well supported standards: HTTP and HTML, which again makes it the most flexible portlet development environment on the market. (You can develop ALI portlets using ANY web server that speaks HTTP and I’ve personally done so using Java, .NET, LAMP, Ruby on Rails, Groovy on Grails and even Domino if you can believe that.) It also supports JSR-168 and WSRP. (In reading about WebCenter, all portlet development documentation was Java-centric, so I’m not sure if they support any other kind of portlet development, e.g. .NET. It’s crucial that any product which claims to be the “face of SOA” supports at least Java and .NET development and plugins; however, many would argue that you need to support much more — e.g. Ruby on Rails, PHP, etc.)

    Leaving portlets out of the picture for a moment, consider the other ALUI integration points: AWS, PWS, CWS and SWS. All of them use SOAP, which is a documented open standard. In fact, in my next blog post (which went up last night), I talk about how I integrated a custom MySQL/Ruby on Rails user store with ALI using a Rails-based SOAP-driven web service to interface with ALI’s user management system. It just doesn’t get any more open than that. At last year’s Participate conference, I demonstrated how you could use the ALI “face” to front WLS applications written to run on the WL message bus and communicating with data stores using DSP, proving that you integrate ALUI products with pretty much anything. I would like to see how a WebCenter consultant or a WLS guy would approach integrating Siebel or PeopleSoft, two products now in the Oracle family.

    I may make many “assertions” (as you call them), but they’re backed up by solid facts. I’m open to continuing this dialog because I want to hear more facts about 1) how you perceive ALUI as a proprietary technology and 2) how WLP and WebCenter claim to support “Web 2.0.”

    Posted by: bucchere on January 20, 2008 at 6:10 PM

  • Out of respect of SEC rules, I won’t touch the Oracle topic. But as for WebLogic Portal (WLP)…2) how WLP … claim to support “Web 2.0.”There are a bunch of features that contribute to the overall Web 2.0 story for WLP. Look at the WLP Groupspace application, for example. Web 2.0 is about publishing social applications that get better the more people use them. Groupspace is such an app. It is first a packaged social app ready to go out of the box, but secondly shows off many of the WLP features in the area of “Web 2.0”.

    Groupspace doc link (community framework, RSS, Groupnotes (think wiki), discussion forums, shared document repository, calendar, contacts, etc, etc).

    Also, read up on Josh Lannin’s blog to see what will be out shortly in terms of WLP and REST, more Ajax, more Portlet Publishing (Google Gadgets, RoR, PHP, etc). Lannin’s WLP futures

    Cheers – PJL

    Posted by: plaird on January 21, 2008 at 8:30 PM

Why I. . . .

whyiA couple weeks ago I teamed up with college buddy, recent Kellogg grad and former PayPal/eBay product manager Chris Gregory to design and write a fun little Facebook application called WhyI.

He did the design and product management, my wife Allison did the logo design and I wrote the code. After a few weeks of hacking in Ruby on Rails (using RFacebook) and many hours of Skyping between Chris and Chris, I’m very pleased to announce that we’re done and the application is live on Facebook!

You can use the app to share five-word WhyI “taglines” about your passions on your profile. You can also ask other people to create taglines by asking them “Why do you?” questions.

If you have any questions or feedback on the application, please comment here or send a note to [email protected].

Four ALI IDKs at your Disposal — Fifth One on the Way?

As most of you already know, there are four IDKs out there in IDK-land. To take a step back, if you’re really new to ALUI (formerly Plumtree) development, you can read about how ALUI handles portlets and how an IDK helps you write portlets. So, back to the four IDKs. They are all freely-downloadable from BEA — I’ve included links here:

*These two IDKs were written by developers at bdg and then released to the open source community on dev2dev’s CodeShare.

edocs warns you in boldface type: always use the IDK. That’s sound advice, given that the IDK API isolates you, as a portlet developer, from changes to the underlying protocol that ALUI uses to communicate between the portal and portlets (CSP). However, what if you’re not writing a portlet in Java, .NET, Ruby or PHP? As an aside, once upon a time, there were Perl and ColdFusion GDKs (predecessor to the EDK/IDK), but these development kits are no longer maintained by anyone, although I know for a fact that the ColdFusion GDK is still in use by an ALUI customer because it came up during a sales call!

So, back to my “what if” question: how can you write a portlet without an IDK? It’s actually not too hard if you’re just getting information from the portal. However, it gets challenging when you start setting preferences and then it starts to get really painful when you start dealing with Unicode issues, encrypted settings and some of the other really hairy stuff. So that’s why edocs implores you to use an IDK, when one is available.

If you do go down the road of writing a portlet in a language where an IDK isn’t available, I highly recommend that you at least abstract out your CSP calls such that they’re isolated from the rest of your portlet code. While you’re at it, you might as well follow the same API that BEA uses; in other words, write your own IDK (or at least the parts of it that you need to get your portlet done). To get you started, here’s how BEA probably implemented one of the IDK methods in Java:

public AggregationMode getAggregationMode() {
  if (!request.isGatewayed()) {
    throw new NotGatewayedException("Request not gatewayed.");
  }
  
  if (request.getHeader("CSP-Aggregation-Mode").equals("Multiple"))
    return AggregationMode.Multiple;
  } else {
    return AggregationMode.Single;
  }
}

So, go forth and write your own IDK. Or, preferably, ask a bdg-er to write one for you!

On a related note, one of our customers recently asked us to build an IDK for Lotus Notes/Domino in LotusScript. We’re trying to figure out if other people might be interested in this IDK so that we can decide if we’re going to open source it or do it as a consulting project (or some hybrid of the two). If you are interested in LN/Domino development for ALUI, let us know by commenting on this blog. I always love hearing feedback from users of the PHP and Ruby IDKs as well.

Comments

Comments are listed in date ascending order (oldest first)

  • Hi Chris. We have a couple of remote portlets on web servers running Perl so I looked around for awhile for the original Perl IDK but couldn’t locate it, so I’ve written a Perl module that supports the methods provided by IPortletRequest. They’re read-only methods but are really all we needed access to. man-page is here…
    http://webdev.co.nz/Perl/IPortletRequest.txt Is this worth placing in codeshare do you reckon? I don’t see a lot of action in the forums concerning Perl use.

    Dean Stringer ([email protected])

    Posted by: deeknow on March 22, 2007 at 2:00 PM

  • Hello Dean! The original Perl GDK was written so long ago that I’m not sure how much good it would do. It was based on CSP 1.0 and it followed the old GSServices API rather than the new com.plumtree.remote.portlet API.

    I’m pretty stoked to find out that someone else has written at least part of an IDK — that’s impressive. Do I think it’s worth posting to CodeShare? I haven’t heard much talk about ALUI and Perl, but I guess it can’t hurt.

    Posted by: bucchere on March 22, 2007 at 5:03 PM

  • Hi, Chris. We would love to have a Lotus Notes/Domino IDK available to us, as we have lots of “legacy” applications in Domino that we want to expose in ALUI, and an IDK would certainly help! Just my nickel’s worth… 🙂

    Posted by: kcepull on March 30, 2007 at 11:21 AM

  • Thanks for your comment. If you don’t mind my asking, would you be willing to pay for such a thing or is it only a nice-to-have that you would download and use if it were opensource, but not pay for it if it were a commercial product?

    Posted by: bucchere on March 31, 2007 at 6:07 PM