restoreAttachedState and saveAttachedState

If you had come across a situation where you wanted to restore state of a non-primitive member variable, and found that it was not working, here is the solution:
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
super.restoreState(context, values[0]);

//Don' do this; it will fail on you!!!
//listenerPointers = (Map<String, ArrayList<Class<? extends ActionListener>>>) values[1];

//This will work!!!
listenerPointers = (Map<String, ArrayList<Class<? extends ActionListener>>>) restoreAttachedState(context,values[1]);
Notice the call to restoreAttachedState(facesContext, value).

"saveAttachedState(facesContext, value) is the saveState() counter-part.

Both are static methods in UIComponentBase class.

RichFaces - selfRendered a4j:Region

For the selfRendered <a4j:region> to work properly, all the components embedded inside it should be UIComponents. In other words, if any html elements are part of the a4j:region, these elements are considered "transient" by the Richfaces framework and hence are lost-in-transit on post-back. If you have "div" tags, change them to t:divs (from Apache Tomahawk Library) or "span" to "h:outptText".

MSC. Software India User Conference 2008

Bangalore Sept 08, 2008: MSC. Software India User conference started this morning. The event is attended by engineers, analysts and executives from various engineering simulation affiliated companies. Amir A. Mobayen, Executive Vice President, Worldwide Sales and Services briefed about MSC. Software's footprints and value-proposition in the Engineering Simulation Discipline. Highlight of the inagural day session was the customer keynote by Dr. Sathya Prasad Mangalaramanan, Section Head, Advanced Engineering, Ashok Leyland.

David Yuen, Vice President, MSC.Software Asia Pacific explained how Enterprise Simulation can help companies simulate more, using MSC SimEnterprise. Dr. TSK Murthy, Global Head of Integrated Engineering Services, Sathyam Computer Services on his keynote touched upon Sathyam's strategic plans to work together with MSC. Software on customizing SimEnterprise product offerings. Doug Niel, Senior Director, Development for MD Nastran gave an overview of multi-disciplinary optimization using MD Nastran.

On his Gold Sponsor keynote, Dr. Swami Narayanaswami explained how MSC partnership helps CSM software to deliver customer value.

Second part of the day included technical paper presentations by MSC Software cusomers.

Please don't forget to check back this space for more exciting updates from day 2 of the user conference.

MSC.Software India User Conference 2008

If you are working in the CAE and Engineering Simulation industry, dont miss out on this exciting opportunity to hear about the latest trends, tools and technologies from the industry leader, MSC Software, our partners and customers.


Early bird registration has closed. If you still have not registered, hurry up!!!

RichFaces Dynamic Menu, Finding Ajax Form, Custom Method Expression and Parameterized Action

Here is a common scenario you will come across while using JSF with RichFaces

Creating Dynamic RichMenu
Register the menu component in your view (Facelets or JSP)

<rich:dropdownmenu binding="#{bean.menuComponent}" value="File">

In the backing bean, use the component binding to create Menu Items programmatically
private HtmlDropDownMenu menuComponent;

public HtmlDropDownMenu getMenuComponent() {
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
if(null == menuComponent)
menuComponent = (HtmlDropDownMenu)app.createComponent(HtmlDropDownMenu.COMPONENT_TYPE);
for(String key: map.keySet()) {
HtmlMenuItem item = (HtmlMenuItem)app.createComponent(HtmlMenuItem.COMPONENT_TYPE);
Class[] params = {};
MethodExpression actionExpression = app.getExpressionFactory()
String.class, params);
String onSelect = "open(this,'"+map.get(key).toString()+"')";
return menuComponent;

Notice how you can programmatically create a Mexpression in JSF 1.2 via UEL
Also, see how JavaScript event is wired to the dynamically created RichMenuItem

Finding the Form
RichFaces has a convenient JavaScript function A4J.findForm which you can use to locate the form corresponding to the Menu Item

function open(el, paramValue) {
var frm = A4J.findForm(el);
if(frm == null) {
alert("open: no form found.");
//add hidden parameter
var hidden = document.createElement('input');
hidden.setAttribute('name', 'PARAM_NAME');
hidden.setAttribute('type', 'hidden');
hidden.setAttribute('value', paramValue);


Managed Bean Action method
From the action method, find the value of interest and take appropriate action

public void menuAction (){
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
Map reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String param = reqMap.get(name).toString();

Feel free to use this code in your applications.
If you found this useful, please leave your comments / feedbacks that would prove helpful for the developer community.

Migrating to Myfaces 1.2

Decorating FacesServlet: More often than not, an enterprise application would require having its business core initialized on Web Server startup and before it can service the first request. The Servlet *init* method is mostly the placeholder to trigger the business core initialization. For that matter, it is quite a frequent practice to decorate the Startup Servlet and call the initializer block from the Servlets init(ServletConfig config) method. In a JavaServer Faces application, the startup Servlet is the javax.webapp.FacesServlet. Decorating a FacesServlet would have worked just fine for you in the earlier versions of JSF (till 1.1). In JSF 1.2, this is no longer the case. If your web.xml do not have the javax.webapp.FacesServlet Servlet mapping entry, your web application will fail to start. How do you go about it?

Well, there is an option. If you are using MyFaces implementation of JSF 1.2 (I use MyFaces1.2.3), your previous decorator Servlet should extend from org.apache.myfaces.webapp.MyFacesServlet. Well, I admit that inheritance is evil. If I find a better way to still work with decorator pattern, I will certainly post the updates here.

Client-side State Saving:

If your JSF web application employs Client-side state saving, you are more than likely to get a "javax.crypto.BadPaddingException: Given final block not properly padded"

Encryption of client-side state saving is supposed to be OFF unless you explicitly enable it, but is in fact ON unless you DISABLE it!

The problem is that if you don't specify a secret (because you think you're not using encryption), MyFaces will generate one and place it in application context; but this will change when you redeploy, and the secret used in pages in users' browsers from before the redeploy will then fail.

To get rid of the error, add the following <context-param> to your web.xml file:





See for further details

Of course, don't forget to modify your web.xml to web-app_2_5.xsd

Back in Orange County...

This year’s MSC SimManager Developer Conference was scheduled at MSC head-quarters in Santa Ana from May 12th to May 16th immediately after the JavaOne week. I did not want to fly alone; which meant, I had to fly to Mumbai from Bangalore so that I can join Aba for the rest of the journey. MSC arranged for airport drop.

Jet Airways flight from Bangalore to Mumbai was quite a pleasurable experience although it had a delayed start of 30 mins. The in-flight entertainment was world-class. Watched two documentaries; “Forbes under 25 great achievers” that featured the likes of Maria Sharapova to Daniel Radcliffe. All the 20 who topped the chart were from Sports, Hollywood and Music industry. Interestingly enough, none of the top 20 were from the technical or business community; no more Sergey Brins or Larry Page or Bill Gates or Michael Dells or Steve Jobs in the making? Or, did I make a wrong career choice as a technocrat? The second documentary was a nice illustration of Barcelona Soccer Club and its evolution. I replayed the video several times to watch one of those Maradona’s stunner; GOAAAAALLLLLL!!!

Mumbai Domestic Terminal was undergoing a major re-vamping exercise; the arrival lobby looked quite spacious that meets international standards; a reminder to outside world of the tremendous growth this country is heading towards in the next decade. The inter-terminal transfer facility was good; thanks to GVK, it was a hassle-free experience to get to the Continental check-in counter to catch my onward flight to Newark. International terminal entrance for Air India, Continental and Thai airways (Terminal 2?) looked a big mess; construction was going on in full swing; dust and pollution all over the space. Worst, they did not leave enough seating for the international passengers. I started walking back and forth in search of a seat and finally spotted one. When I was about to occupy it, the Israeli who was seated next interfered;” sorry, this seat is taken”. Moments later, his Chinese co-traveler returned with coffee-cups for both.

An hour later, Aba reached. He looked very relaxed even after several hours of travel from Pune. Together, we finished filling up the forms. It is always a pleasure to have a co-traveler during international travel. Continental flight C0 49 to Newark was delayed by 45 minutes. We completed the check-in formalities and proceeded towards the gate. The security check has become much more trouble-some over the years. Right from the Continental Security folks asking several questions to the extend of having to remove footwear and belts; makes air travel as less pleasing as possible.

CO 49 from Mumbai to Newark is a Boeing 777 long-haul flight for a non-stop 16 hours. The in-flight entertainment system was pathetic. For alcoholic beverages, you end up paying USD 5 per can. The crew is not as nice as you would expect them to be. Continental considers passenger safety as their prime concern. 16 hours were fair enough for me to carefully skim through Freakonomics, watch 27 dresses, Dhan Dhana Dhan Goal and an episode of Friends. The gentleman on my left was a veteran Tata Engineering Services manager with over 25 years experience in the industry. While the aircraft was heading through a moderate turbulence, his explanation of CFD Simulation of Turbulence helped me stay at peace. May be the industry I work has matured enough that most of these scenarios are well simulated and tested.

CO 49 landing at Newark was simply spectacular; like a feather-touchdown; thanks to experienced Continental Captain. Trust me; you may fly with no fear!!

Newark international Airport is big and spacious. The emigration process was very smooth. We collected the bags and checked them back again to the connecting flight to LAX. Continental domestic flight from Newark to LAX has a total flying time of 5.30 hours. On my third connecting flight and after loosing a night’s sleep, I was counting seconds to get out of the aircraft. There was not enough space on the overhead compartment that left us to leave the heavy and bulky Dell Precision M90 under the seat in front of us. That leaves no leg room any more. I couldn’t sleep nor could I stay awake. As I was assigned a window seat, I could not even walk up to the aisle. The old lady who occupied the aisle seat was already furious that the passenger sitting behind her, accidentally spilled coffee over her dress. So, there was no courage left in me to ask for room to get out of the seat to stretch my legs. Most of the body was aching and tired and I felt extremely uneasy. Can they not accelerate this aircraft any further? Oh, these days, in order to save aviation fuel, most of the jets have started flying slower. That just adds on to my already handful woes.

LAX looks just the same as it did two ears ago when I left US. The whether however was unusually cold for this time of the year. We hired a Supershuttle to reach DoubleTree hotel in Santa Ana. Orange County is one of the costliest counties in the whole planet. The place looked just as elegant as it claims to be. DoubleTree - the Hilton Hotel seemed to have more than 90% of the occupancy for most part of the year with Executives meets, wedding and other functions. I checked into their cozy apartment, quickly got refreshed to get out to find our lunch. We tried the Quiznos FireEater chicken. I guess we ignored “the warning” and had to pay the price. It was as hot as it can get. I never expected such a hot dish in a US restaurant.

Evening, we spent lot of time at South Coast Plaza. I was very particular to locate the Apple store so that I can touch and feel a real iPhone. iPhone qualifies for all the praise it got as the cool gadget of the year. It was very tempting to buy one, but I realized that if I do so, I will have no money left for food to survive the rest of the week.

We then set off to a hunt to find a travel adapter so that we could plug-in our laptops during the conference. After failed attempts at Sears and Office Depot, we landed at RadioShack. Just when we were picking it up, I saw another person asking the salesman questions about the same adapter. It was Georg! And there was Horst walking in zipping a large-size soda. It was quite a pleasant surprise. Horst looked trimmed down a bit. As usual, they were successful in hiring a German car; a Volkswagen. We went to Vons to pick up some essentials for the rest of the week. Back at hotel, I slept like hell till Aba woke me up at 6:00AM for breakfast.

..get need a break!

...and yet again...
...bloomed the dawn of today...
...mingling yesterdays... to the mist of memory..!

Posted by Picasa

Smart...Techy...Innovative...and bored?

We need you if you are:
  • B.E/B.Tech/M.Tech or equivalent between 3 - 5 years of hard core Java, J2EE experience.
  • Comprehensive knowledge in core and advanced Java programming (J2EE).
  • Advanced knowledge of Web programming (XML, XSD, XSLT, Web Services), Web application UI development (JSP, Servelet, JSF, AJAX, javascripts, etc), current Web standards and technologies.
  • Advanced knowledge of multi-platform development (Tomcat, WebSpher, Weblogic) and related issues while developing on these platforms.
  • Advanced Knowledge of different database (Oracle, DB2, MS SQL Server)
  • Advanced structured or object-oriented system design methodologies; ability to produce commercial grade software.
  • Advanced interpersonal, oral, and written communications skills.
  • Develop, Test and maintain components of the SimManager product suite.

More details at

Send your resume to with subject line "Developers and Senior Developers for SimManager"