Thursday, December 23, 2010
Back to India Voyage - If it's not Fire, it is Water
Back to India Voyage - Pranavi's mis-adventure
Sunday, July 25, 2010
Back to India Voyage - Blackness of Smoke
This is another one of those incidents that happen to the chosen few, which would unsettle and unnerve most frail hearted.
We are slowly getting into a rhythm, and it is one of those beautiful Hyderabad evenings, when I came home. Geetha and Kids have gone out, and having not taken the key, I was walking outside and enjoying the cool breeze. I found out that, Geetha went to take Dhruva for his chess class. We have someone in the complex giving chess classes and wanted to take advantage of that (I liberally use the word We here, but Geetha is the one who found it out and took Dhruva there. Give credit where it is due I say). Dhruva is also getting enrolled into a Tai-Kwondo class and I am beginning to believe that there is a sense of belonging here in this complex.
Walking outside the walking rail (I don't know if I mentioned this, but there is a 1 KM walking trail round the perimeter of the buildings in the complex, which I should say is very nicely maintained and pleasant) for the first time, I was catching up on my phone calls. Around 7:30 I realized that Geetha has reached home, I stopped my walk and entered the house. Nothing out of the norm.
Preparing the kids for dinner, we asked Dhruva to go upstairs and get dressed in his pajamas. He goes up and in a flash comes running down saying "There is smoke and fire upstairs". I did not believe him and went along with him. That is when it struck me. The entire upstairs is pitch dark, could not see a thing with lights on, and as I walk I could see my steps in white on the floor. I came down stairs and see my legs, clothes already beginning to turn black. Pranavi starts yelling out "call the fire people".
We called the building maintenance right away and told them that it is an emergency and they have to rush. To their credit, they showed up in less than 5, and went upstairs. They were literally choking whilst trying to find the problem area. I myself went and looked at potential problem areas ( clothing iron, electric geyser etc) and could not find any. But, the professionals quickly found it out and told us that it was the electric geyser in the common bath room that got burnt beyond belief and shut down that part of the electric circuit and told us to stay away from upstairs and left.
This is when I went upstairs to assess the situation. Off late, I am coming across more situations that are truly ineffable. One has to see the room to understand the gravity of the problem. I could go on an on explaining how we felt or what we saw, but, it would surely fall short of reality, but, that does not mean that I am going to give up. I feel that a little (I mean very little) detail would help put things in perspective. So here it goes.
When we rented this apartment, we did it in a rush. We liked more features in this apartment and complex, but were some nagging issues that are still making us regret our hastiness. This apartment had 3 bathrooms and all of them fitted with electric geysers, of which we were using 2 regularly. The one in the common bathroom upstairs, was disconnected. So, we had it checked by electrician who simply connected the wires and said it is working now. When it was turned on, there was some issue with plumbing and it started leaking steam like a cooker with a blown safety valve. So, we called the plumber and he turned the water connection off. What we did not realize in this process is that we had a left a hot plate with nothing to cool it, had some one switched the geyser on.
Dhruva was asked to clean himself up that evening, and quite unusual for him, he used the common bath room and in trying to turn the light on, he turned the geyser on, but did not turn it off. The unit was on for 2 hours without any water to heat. Perfect recipe for disaster. Now lets get back to the situation at hand.
What once was a geyser is now a black cylinder (red hot) and all the plastic surrounding it is completely vaporized into soot. I am looking at a 2-3 mm layer of black soot on the ground, on the bed, and what I saw earlier as my foot prints in white are the clearing of the soot my my feet. The walls over 3 feet from ground are all black including the false ceiling. There was a 1mm of black coating in the closets (housing our clothes) that were locked shut. Few tiles in the bath room were cracked due to heat. The false ceiling in the bath room is charred and had to be replaced. The said Geyser is now a carcass waiting to be dumped.
The thing that made the situation complex was our mosquito nets on the windows which contained all the smoke and soot indoors as opposed to letting it out. We opened all windows and took out the nets thinking even the mosquitoes have some code of ethics and would not encroach an environment so inhospitable (little did we know their tenacity and hunger for human blood).
We were in panic mode, and I decided to take control of the situation as opposed to the contrary. We called for the cleaning crew and this being almost 9 PM at night, they said they could only come in the morning. Being a veteran of cleaning jobs owing to my janitorial training and work experience in school, I decided to take a first crack at it. I slowly but surely collected my wits and along with it cleaned up the soot on the ground. Being so light weight, it flew off into air when I tried to speed up the process. On this occasion my mind was wandering if the choice of marble for the floor should be white or black. If it is black we would not notice much of a difference, but on the other hand, we would not even know how big the problem was. After about half an hour of this clean up, I dared call Geetha upstairs to take a look. Now that both kids are asleep, We could not leave it in that shape and decided to give our best shot to the floor at least.
Good old bucket of soap water and a cleaning rag was the call of the day. So, we started that way. A clean bucket of water is pitch dark by the time we finished one block of marble (2ft X 2ft), and realized that we could not work in that manner if we have any plans of finishing before dawn. So, we went the professional way, dumping the water on the floor and cleaning with a huge mop and it took both of us 4 back breaking hours to at least see the spots of white marble under the black coating.
By the time we were done, we both resembled the coal workers of South Africa. We decided to call it quits as that point, as we were exhausted physically, mentally and emotionally. Even after showering for an hour the blackness did not go away.
We hired professional cleaners next morning and they were scared to start the work. Halfway through, they gave up and said they would only continue after painting the walls and ceiling. I kept thinking, how would they have reacted had they seen the house the day before.
We had the house repainted, and it took a complete scratching of the surface with emery paper, a coat of primer and in some areas up to 5 coats of paint to cover the blackness underneath. All in all after 3 days of that painting job, the cleaning crew gained courage and started to clean the floors and the bathroom which is marked "Enter at your own risk". Another 2 days of that, and now we could hardly imagine how the house was. The painting crew and the cleaning crew have done a superb job turning a disaster area almost back to its normalcy. Every now and then I see a small forgotten spot, a switch with a smoke mark, an overlooked corner of a tile etc that reminds me of the fact, but otherwise, we are back to normal (or whatever you want to call it).
What is surprising to me to this day is through all this, we did not have even the faintest of idea or the stench of something burning downstairs.
On hind sight, it is one of those things, one would think, "It could have been worse" and leave it at that.
Wednesday, July 14, 2010
Back to India Voyage - Rats and BSNL
Since my landing in the mother land, I have called numerous telecom providers asking for internet connectivity. In the land of IT, I got apology mails from the likes of Airtel, Tata etc saying they would not be able to provide service in my building. Then I found the brave soul BSNL, who took it to heart and promised me a service.
Encouraged by this new found enthusiasm, I have applied for a land line and broad band connection (a guarantee of 2 MBPS) online. Waited an eon and then, saw another advertisement from BSNL and sent them SMS requesting the same service. For good measure I followed it up with phone calls a week later.
Really on the wits end, last week I went to BSNL office and inquired about the status of my application. Not much surprise there, I was greeted with a friendly (wink) face who asked "What Application". I repeated my story. With a very understanding smile, she said, "Oh! you are from US. Generally, when you file an online application, you have to come to office and file a paper application." Little did I know about this highly advanced technological advancement. Having been in India for over a month now, I duly complied and filled in an application form for a land line and broad band connection and filled in the fees. Along the process I gave my proof of address, identity proof, a photograph, my current bill, a pint of blood, appendix and pancreas (who needs these organs anyway).
Now comes the twist. She gave me the application and asks me to go to another office (behind this office) and get permission from Mr. Nagaraja Rao. Like a stupid I ask "Why". She said, she can only take the application if he approves. Frankly I got confused (to my knowledge this does not happen very often), but what other option do I have. So, I went to the other office and saw the mentioned Nagaraja Rao, who looked at me and said, "File the application in the front office". I told him, that I was sent from the front office to see him. He said "you fulfilled the formality. so, now I'm telling you to go and file the application". I tried to assess the situation, but thought better of it and filed the application.
The CS rep, then took my application and after 15 minutes, told me that their systems are slow, and she would fill in the form later, but meanwhile, she gave a hand-writeen receipt that I applied for the said services and duly signed and put a rubber stamp and gave me the receipt. Methinks, "If their systems are slow to enter/process my application, how could provide me a 2MBPS service".
I am a patient man (a virtue I acquired recently and have been using and abusing it) and waited 4 days. Nothing happened, and I went to the BSNL office once again to inquire about my application (Paper application this time). They took my name, and the unequivocal paper receipt, and then told me that there is a problem with my application. I asked them what it was. It just so happens that India is booming with people looking for cell phones, and they ran out of 9 series and 8 series. When my turn came, I got a 7 series number and BSNL system does not like this (as it thinks this is a bogus number). My feelings exactly ("Are you kidding me"). Some how, I managed to convince them that they can call that number, which they did and fixed that issue. Now another problem with the application is that I chose a 2 MBPS package which is the highest they offered, and it is on the paper application form, but not yet in their system. I asked them why they could not have told me that on the day I filed the application. They answer promptly was "You did not wait till the application was filed. So, we could not have envisioned what all problems the system gives without entering the data".
I asked them to give me any plan they can enter in the system. I was asked to call back in the afternoon to get an Order #, then call Mr. Nagaraja Rao to expedite the order. Do you See the pattern here? By now a seasoned citizen, I called in the afternoon and got the order number and called Mr. Nagaraja Rao. He tells me, he is not in a position to promise anything. This is when I lost it. I blasted him and talked to few others and finally someone up or down the chain promised to expedite the order.
Real shocker, an hour later, Geetha calls to tell me that BSNL people are home installing the land line. I was surprised, shocked, and beginning to think, I should have blasted these people a month ago and I would have been in Gigabit land. Lesson learned, and mission accomplished.
It would not be a Krishna Story if it ends at this point. So, the story continues..
Geetha calls again, and says the BSNL people can not install as there is some problem. We call the building maintenance people and between them and BSNL folks, identified the problem. RATS. Yup, you read it right, Rats chewed the cable running from BSNL end point in the building to where it joins in my (or the one I rented) apartment. It is not the responsibility of BSNL. RATS.. that's all I can say. So, now I am in the hunt to find whose responsibility is it, and get the wiring installed.
BSNL people promptly left saying "Let us know when you install that cable and we'll install the land line". Now, I can not even blast them, as they can say "Talk to them rats in your building", which could mean so many different things...
Rats.. rats.. rats...
So, in conclusion, "Have you seen rats lately?"
Krishna
Tuesday, August 4, 2009
Adobe Flex & Struts 2.0 Integration
In this article, I am going to explain how to integrate Flex presentation layer with Struts (2.0) server side. To make the process of creating new projects using this methodology, I have created a Maven archetype, that when installed, would create a sample project with the example explained in this article.
This article assumes understanding of Struts and Flex programming and not going into the details of the corresponding frameworks.
Submitting Flex Form Data to Struts Form
In this section we are going to discuss the submission of Flex form data to a struts action. The form data consists of product details, which when sent to the struts action, would be converted to java object and saved in the action.
Step 1
Create a Flex Form that contains the data fields 'productName', 'productDescription', 'productPrice', and 'productQuantity'.
<mx:Form id="addProductsForm" label="Add Product Form" width="100%" height="60%" >
<mx:FormHeading label="Add Product Form">
</mx:FormHeading>
<mx:FormItem label="Product Name:">
<mx:TextInput id="productName">
</mx:TextInput>
</mx:FormItem>
<mx:FormItem label="Product Description">
<mx:TextInput id="productDescription">
</mx:TextInput>
</mx:FormItem>
<mx:FormItem label="Product Price">
<mx:TextInput id="productPrice">
</mx:TextInput>
</mx:FormItem>
<mx:FormItem label="Quantity in Stock">
<mx:TextInput id="productQuantity">
</mx:TextInput>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Add" click="addProduct()"/>
</mx:FormItem>
</mx:Form>
Step 2
Create the service that invokes a Struts action. This service defines the methods to be invoked for the successful response and on failure.
<mx:HTTPService id="addProductService" showBusyCursor="true" useProxy="false"
url="addProduct.action" resultFormat="e4x" method="POST"
result="addProductResult(event)" fault="addProductFault(event)"/>
Step 3
Create the method that gets called when the button was clicked. This method creates a dynamic object with the attributes of the form data and submits the 'addProduct Service'.
public function addProduct():void {
var params:Object = { 'product.name': productName.text,
'product.description': productDescription.text,
'product.price':parseFloat(productPrice.text),
'product.quantity':parseInt(productQuantity.text)
};
this.addProductService.send(params);
}
Step 4
Process the response from the server. In case of error, display the error message. In this example, we have not applied any filters on the output result of the action. So, a complete XML representation of the action class would be sent back to the Flex as a response. Look for the 'status' variable and see if it is true and if so, the product was added successfully, else the details of the errors are stored in the 'actionErrros' variable of the Struts action object.
private function addProductResult(event:ResultEvent):void {
var xml:XML=XML(event.result);
var status:String = xml..status;
if (status != null && status.toString() == "true") {
mx.controls.Alert.show("Product was added Successfully!");
var messages:XMLList = xml..actionMessages.item;
actionMessages.text = messages.toString();
}
else {
var messages:XMLList = xml..actionErrors.item;
actionMessages.text = messages.toString();
mx.controls.Alert.show("Product was NOT added. See messages below");
}
}
The complete Flex application can be seen here.
Step 5
Create Struts configuration file, and define the action mapping with the result type as XSLT. This configuration would marshall the complete action class into XML stream and send it to the requester, in this case the Flex application.
<action name="addProduct" method="addProduct" class="com.company.flex.action.ProductAction">
<result type="xslt"></result>
</action>
Step 6
Define the POJO for the Product. And Create the Action class that extends the action support. The 'addProduct' method checks for the validity of input, and if validated, adds the product to the static product list and sets the status as true, else sets teh status as false.
public String addProduct() {
this.status = true;
if (this.getProduct() != null) {
Product p = this.getProduct();
if ( p.getName() == null p.getName().equals( "" ) ) {
addActionError ("Product Name can not be blank" );
this.status = false;
}
if ( p.getPrice() <= 0 ) {
addActionError( "Product Price has to be a positive number" );
this.status = false;
}
if ( p.getQuantity() <= 0) {
addActionError( "Product Quantity has to be a positive number" );
this.status = false;
}
if (status) {
getProducts().add( getProduct() );
addActionMessage( "Product " + p.getName() + "[" + p.getPrice() + ", " + p.getQuantity() + "] was added" );
System.out.println( "Product " + p.getName() + "[" + p.getPrice() + ", " + p.getQuantity() + "] was added" );
}
} else {
System.out.println ( "Product Object was not set for the action" );
addActionError( "Product Object was not set for the action" );
this.status = false;
}
return SUCCESS;
}
A complete example project can be downloaded here. This project is a maven project and you need maven version 2.2.0 to execute this project. I am using the maven flex-mojos for compiling and building the mxml and actionscript files, so you need to update your corresponding settings.xml file in your home directory.
Fetching Data from Struts Action
In this section we are going to discuss how to fetch data from a Struts action and display it in Flex application. For keeping this article simple, we are going to fetch the static data from the action class, but this could be easily extended to fetch the data from a server side file or database. This involves using the "xslt" result type of struts action (available in 2.0).
Step 1
Define a Flex form that has a button (We are not sending any data to server, however that change can easily be made) and a display grid for displaying the results.
<mx:Form id="detailsForm" label="Get Details Form" width="100%" height="100">
<mx:FormItem>
<mx:Button label="Get Product Details" click="getProductDetails()"/>
</mx:FormItem>
</mx:Form>
<mx:DataGrid id="dg" color="0x323232" width="100%" height="90%" rowCount="3" dataProvider="{products}">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Product Name"/>
<mx:DataGridColumn dataField="description" headerText="Description"/>
<mx:DataGridColumn dataField="price" headerText="Price"/>
<mx:DataGridColumn dataField="quantity" headerText="Quantity in Stock"/>
</mx:columns>
</mx:DataGrid>
Step 2
Create the service that invokes a Struts action. This service defines the methods to be invoked for the successful response and on failure.
<mx:HTTPService id="getDetailsService" showBusyCursor="true" useProxy="false" url="getProductDetails.action" resultFormat="e4x" method="POST" result="getDetailsResult(event)" fault="getDetailsFault(event)"/>
Step 3
Create the method to submit the form and get the results from the struts action. In this case, this is a dummy action method and we are fetching the data from the action itself.
public function getProductDetails():void {
var params:Object = {};
this.getDetailsService.send(params);
}
Step 4
Define the Struts configuration for this action in struts.xml file
<action name="getProductDetails" method="dummy" class="com.company.flex.action.ProductAction">
<result type="xslt"> <param name="exposedValue">products</param></result>
</action>
Step 5
Define the action method and a property 'products' in the action class.
public ArrayList<Product> getProducts() {
if ( products == null ) {
products = new ArrayList<Product>();
Product prod1 = new Product();
prod1.setName( "Canon Rebel Xi" );
prod1.setDescription( "Digital SLR Camera from Canon." );
prod1.setPrice( 456.50f );
prod1.setQuantity( 2 );
products.add( prod1 );
Product prod2 = new Product();
prod2.setName( "IPhone 3G" );
prod2.setDescription( "3rd Generation Smart Phone from Apple" );
prod2.setPrice( 199.99f );
prod2.setQuantity( 10 );
products.add( prod2 );
}
return products;
}
public String dummy() {
return SUCCESS;
}
For complete application example, please see the resources section below.
Maven Archetype for Flex-Struts Project Creation
To make the creation of Flex Struts projects easier, I have created a Maven Archetype (using other open source components available on-line like flex-mojos etc).
Step 1
Download the maven archetype zip file from the resources below.
Step 2
Extract the contents into a folder, and run maven install command. This would install the archetype into your local repository
mvn clean install
Step 3
Now you can create a new project from the archetype specifying the local catalog. All the local archetypes are listed, and selecte the FlexStruts-archetype option. Then the installer would ask input for the parameters like 'groupId', 'artifactId', 'version' and package. Provide the requested information and a new project would be created for you.
mvn archetype:generate -DarchetypeCatalog=local
See the following screen-shot for how the output looks.
Step 4
Go to the newly created project and run Maven install command and a War file would be created in the target folder for the web module of the project. Deploy this war in an application server and you can test the Flex Struts in action.
Resources
- Example Project FlexStruts.zip
- Maven User settings.xml
- Maven Archetype Project.