Implementing Navigation and Pageflows with Seam

This article is published on JavaLobby / Dzone.

Seam is an interesting web framework that integrates the different pieces of the application stack and incorporates ideas from rules engines, BPM engines and SOA into regular application development. In this article, the focus is on Seam’s navigation and flow related features. Let’s see how they could play out in practice.
The article logically divides the topic into two parts, which map to the two navigation models, namely stateless and stateful. In Seam, stateless implementation uses JSF style pageflows while the stateful implementation uses jPDL pageflows.

Navigation models

Navigation from page to page, or view to view, in a web application can either be agnostic to or be governed by the state of the application. In other words, it could be stateless or stateful. In a stateless model a set of rules map action or event outcomes to specific views or pages. On the contrary, in a stateful model the navigation rules define transitions from one state to the other, which in the process causes transition from one view or page to the other. You may ask why navigation models need to be stateful at all and you may also ask how the state information could be tied in with the navigation rules. Both the questions are pertinent and important so I will try and answer them right away.
In a process driven web application the flow from one page to the other is often governed by the application state and the decision tasks which use this state information. As an example, consider a loan processing application manifesting as a web application. In this application a user could be transitioned from the “welcome page” to the “loan information capture page” or “modify and confirm information page”. The choice of the page to transition to will depend on the applicant being an existing approved customer or not. An existing customer would be sent to the “modify and confirm information page” since most information pertinent to the loan processing is already available, while a new customer would be directed to the “loan information capture page” as basic information needs to be available before any further decisions can be made. Assume that such an application also gives the user a choice to upgrade its approval status. As an example the particular user may be approved for loan upto $500,000 but now needs to upgrade the loan approval amount to $1 million. In this example at the “modify and confirm information page” the user will choose to upgrade the loan amount and so would be diverted to “get additional information page”. You see what is happening here, the navigation is essentially mirroring the viable transitions which depend on the current state of the application. It’s a state transition scenario, that’s it! This flow is depicted in Figure titled: “The loan approval application process flow”.

Read more

Flex HTTPService, Browser Cache and IE

This morning I spoke at a Flex event in Hyderabad (India). Our (Saven Technologies) team members at Hyderabad planned and organized this fantastic event. It was a public event. Over 200 enthusiatic people attended the event.

I sincerely appreciate the effort of the organizers and thank the attendees for making it a successful event.

One of the attendees asked me a question about problems with Flex HTTPService and the IE browser cache. I promised to provide a detailed solution to the problem, so here it is:

Problem: Repeated HTTPService calls when made from Flex (running within an instance of the IE browser) many a times ends up with no external HTTP call. It appears the data is served from cache.

Reason:  The Flash Player piggybacks on the browser to make the HTTP call. IE caches the response from the HTTP GET calls and on occurrence of the same URL returns the response from the cache.

Solution: The problem can be solved either at the server side or at the client side.

Server side solution:  Set the HTTP headers of the response to avoid returning response from cache.

In HTML: (in the header)

<META HTTP-EQUIV=”Cache-Control” CONTENT=”no-cache”>
<META HTTP-EQUIV=”expires” CONTENT=”0″>

In PHP: (in the script)

header(”Cache-Control: no-cache, must-revalidate”);
header(”Expires: Mon, 26 Jul 1997 05:00:00 GMT”);

In JSP: (before writing to the output stream)

response.setHeader(”Cache-Control”,”no-cache”);
response.setDateHeader (”Expires”, 0);

Client side solution: (1) Make HTTP POST call — only HTTP GET calls are served from cache or (2) Make sure the HTTP GET URL is different every time.

(1) Make HTTP POST call –
set method=”POST” and handle the call appropriately

(2) Append a unique parameter to the HTTP GET call so that the URL is different every time. A unique time stamp is a good choice.
The following sample code, may do the job:

var timeStampForNocache:Date = new Date() ;
params.noCacheControlVar = timeStampForNocache.getTime().toString() ;
I have named the parameter “noCacheControlVar”. You can name it anything else you please. The name does not matter. What matters is that the timestamp makes the HTTP GET URL unique.

That’s it! Hope it helps and IE does not trouble you when using HTTPService anymore.

SWF is Searchable

Adobe SWF files that run in the flash player will now be searchable. Adobe published SWF searchability FAQ earlier this morning explaining the details of what this implies.

Web spiders will now be able to playback SWF(s) like users and cull out the data to add to their index. This announcement has two huge impacts:

Congratulations to Adobe, Google and Yahoo for this new development.

Flex Camp Wall Street: 1 day and 1 seat to go!

Flex Camp Wall Street is just 1 day away and we are also 1 seat away from being sold out! I must thank every attendee, organizer and speaker for generating the excitement about the event. We increased seats to include 150 instead of our initial number of 125 and yet it took no time for the seats to fill up. I hope everybody enjoys the event tomorrow and promise to organize more events of the type in future.

Thanks!

Adobe Developer Week 2008 : Flex and Java — Tying the knot!

Thanks to all those who attended my session earlier this afternoon. I will post answers to many of the questions that were asked and could not be addressed (due to shortage of time). Please navigate to the page titled — “Flex and Java” — and you will see these spread across multiple posts on that page.