Archive for August, 2009

26th Aug 2009

Introduction to Palm Pre Development

Palm Pre

Palm Pre

Palm Pre is mobile technology and it mainly includes the following functionality

  • Move and open multiple applications very easily.
  • Palm Services like Backup and restore important data and erase data remotely if phone is stolen or misplace.
  • Palm web OS™ platform are integrated with other apps on the phone

What is webOS?
Palm webOS is an embedded operating system developed by Palm, Inc. for a range of devices. It includes many features like designing, coding and debugging.

What is Mojo?
Mojo is “an application framework based on the HTML5, CSS, and JavaScript standards”.  Applications built with Mojo “are installed and run directly on the device at native speeds and have access to a wide range of device services”.

While Mojo should be sufficient for developing a wide range of applications, other graphics-intensive programs such as games would probably require a lower-level webOS API.  There has been some speculation that Palm will release a second API that enables developers to access the hardware more directly for these types of applications.

Scene:
Scenes are mutually exclusive views of the application within a stage. Most applications provide different kinds of scenes within the same stage, while simple applications (such as Calculator) only have a single scene. Typically, a new scene is pushed after a user action, such as a tap on a UI widget, and the old scene can return with a “back” gesture. Scenes are managed by a scene stack, with new scenes pushed onto and off of the stack with the last scene visible.

Scene assistant:
A scene assistant is a “controller” for a scene.  It contains the logic behind how the scene behaves and responds to user input.

Widgets:
Widgets support webOS user interface, and Mojo definies styles for each of the widgets. The styles are available simply by declaring and using the widgets, or they can be overridden either collectively or individually with custom CSS.

The List widget is the most important in the framework, as “the webOS user experience was designed around a fast and powerful list widget, binding lists to dynamic data sources with instant filtering and embedding objects within other widgets and lists.”

Simple widgets include buttons, checkboxes, sliders, indicators, and containers.

The Text Field widget includes text entry and editing functions, including selection, cut/copy/paste, and text filtering, and can be used in conjunction with a list widget.

Menu widgets can be used with specified areas of the screen, including the view and command menus that are completely under your control. The app menu is handled by the system, but custom items can be added to the menu, as well as functions to service the help and preferences items.

Picker and viewer widgets are more complex, with pickers used for browsing and filtering files or contacts, or for selecting addresses, dates or times. Viewers are used to play or view items such as audio, pictures, video or web content within your application.

Requirement for development in Palm Pre

How to start development in Palm Pre?
Before starting development in Palm Pre you need  to download VirtualBox, Mojo SDK and Eclipse 3.4.2 version. Install VirtualBox first, then only download and install Mojo SDK. It is pre-requisite for Mojo SDK installation. When you start installing Mojo SDK, make sure that VirtualBox is not running.

Now Double-click the Palm SDK Installer file.

  • The Palm emulator becomes available in the Applications folder.
  • The Palm command-line tools become available from the Terminal.
  • Create or choose a directory to use as your application development workspace.

You can start the Palm Emulator by double clicking on its icon in the Application directory. At that time Virtual box starts up and creates virtual machine that hosts the Palm Web OS Platform. When you start VirtualBox first time there are several message will come. Just click ok on that diaglog box and continue.

In Eclipse you need to add Mojo SDK plug-ins. For that,

  • Start Eclipse.
  • go to Help Menu, Select Software Updates and click on Available Software tab.
  • click and select Add Site button. and in the location field http://cdn.downloads.palm.com/sdkdownloads/1.1/eclipse-plugin/eclipse-3.4/site.xml and click Ok.
  • check Palm Mojo SDK and click Install.
  • Restart Eclipse.

After installing Mojo SDK add plugins in the Eclipse,

Selecting the webOS Perspective

1.  Select Window > Open Perspective… > Other…

2.  Select webOS from the Open Perspective dialog.

3.  Click OK.

Preparing  webOS Application

From the New Project menu:

1.  Start Eclipse.

2.  Select File > New Mojo Application.

3.  On the next screen, type a name in the Project Name field.

4.  Enter your application info:

    • Title
    • Vendor
    • ID
    • Version

5.  Click Finish.

From the New App toolbar menu:

1.  In the Eclipse toolbar, click the Mojo Wizard icon and select New App from the drop down menu.

2.  On the New Project Wizard screen, type a name in the Project Name field.

3.  Enter your application info:

    • Title
    • Vendor
    • ID
    • Version

4.  Click Finish.

Adding a scene to your webOS Application,

From the New Project Menu:

1.  Select File > New > Mojo Scene.

2.  On the New Mojo Scene Screen, make sure the correct project is selected.

3.  Enter a name for your scene and click Finish.

From the New Scene toolbar menu:

1.  In the eclipse toolbar, click the Mojo Wizard icon and select New Scene from the drop down menu.

2.  On the New Mojo Scene Screen, make sure the correct project is selected.

3.  Enter a name for your scene and click Finish.

Running a webOS Application

1.  Select Run > Run Configurations…

2.  Select Palm Application and click the New Configuration icon to create a new launch configuration.

3.  Change the name.

4.  Select your project from the drop-down list.

5.  Select the Target:

    • Palm Emulator if you are using the emulator.
    • Palm Device if you are using a device (make sure your device is in Developer Mode).

6.  Click Run to install and run the application.

Installation starting problem when you run emulator first time.

If you are running on installing the application for the first time in Palm Emulator there is a possibility of getting following error.

Error Message

Error Message

To fix it you simply need to enter the following two commands in your terminal command prompt:

$ sudo chmod 644 /Library/LaunchDaemons/com.palm.novacomd

$ sudo /opt/nova/bin/post-install.sh

For more information please go through following site, you will find out more regarding this error.

http://www.ozmox.com/2009/07/25/webos-on-mac-os-x/


Tutorial of your First Palm Pre Application development:

Now how to develop first Palm Pre Application, following steps will guide you in details of Palm Pre development.

For that from New Project menu:

1. Start Eclipse.

2.  Select File > New Mojo Application.

Give the name of the application.

What is a Stage?

Now in the application you need to set the stage. A stage is the platform on which you build the user interface for your application. A stage generally corresponds to a single card, or application window. Most simple applications have a single stage, contained in the file index.html. An application that lets the user perform more than one action concurrently might require more than one stage. For example, an email application might show the inbox on one stage, but launch a second stage to compose a new email message. Notification and background applications have no stages at all.

So change in the Index.html page.

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”

“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en“>

<head>

<title>PalmTest</title>

<script src=”/usr/palm/frameworks/mojo/mojo.js” type=”text/javascript” x-mojo-version=”1″ />

<script src=”app/assistants/stage-assistant.js” type=”text/javascript“></script>

<script src=”app/assistants/first-assistant.js” type=”text/javascript“></script>

<!– application stylesheet should come in after the one loaded by the framework –>

<link href=”stylesheets/main.css” media=”screen” rel=”stylesheet” type=”text/css” />

</head>

<body>

<h2> Testing Application

</h2>

<p>

One stage application

</p>

</body>

</html>

Now create new scene named “First-scene”. It will add two files and one json file.

The palm-generate command creates the view and the assistant for the first scene. It also adds a few lines to sources.json to correlate the assistants and scenes. Take a look at the following files:

  • /app/views/first/first-scene.html — This is the view.
  • /app/assistants/first-assistant.js — This is the assistant.
  • sources.json — This file now includes JSON information that binds first-assistant.js to the first scene.

Now modify the first scene html file for adding new controls.

Open first-scene.html and replace the content with the following

<div>

<div class=”palm-header”>Header</div>

<div id=”count”>0</div>

<div id=”MyButton” x-mojo-element=”Button”></div>

</div>

Now to show the scene, you have to tell stage to push the scene.

To push the application scene

1.  Open stage-assistant.js.

2.  Edit the StageAssistant function to contain the following:

function StageAssistant () {

}

StageAssistant.prototype.setup = function() {

this.controller.pushScene(”first”);

}

Now how to bind and register the handler, there are two steps.

  • binding the handler to the scene assistant’s scope, using bind(this)
  • registering the handler as a listener, using Mojo.Event.listen()

Now open first-assistant.js and edit setup function and add following code into that.

FirstAssistant.prototype.setup = function() {

// set the initial total and display it

this.total = 0;

this.controller.get(”count”).update(this.total);

// a local object for button attributes

this.buttonAttributes = {};

// a local object for button model

this.buttonModel = {

“buttonLabel” : “CLICK HERE”,

“buttonClass” : “”,

“disabled” : false

};

// set up the button

this.controller.setupWidget(”MyButton”, this.buttonAttributes, this.buttonModel);

// bind the button to its handler

Mojo.Event.listen(this.controller.get(”MyButton”), Mojo.Event.tap, this.handleButtonPress.bind(this));

}

After creating build, run the application. It will shows the count that how many times you pressed “Click Here” button. It will increase every time you press click button.

PalmPre Sample

PalmPre Sample

Same way you can add more than one scene and navigate from one scene to other scene using following script which will help you to redirect to second scene by pushing the scene.

FirstAssistant.prototype.nextScene = function(event){

if (this.textModel.value == “Testuser”)

{

Mojo.Controller.stageController.pushScene(”second”,this.textModel.value,this.Passowrdmodel.value);

}

else

{

this.labelmodel.value=”Invalid User and Password”;

}

}

And you have your first Palm Pre application ready! I hope you enjoy Palm Pre development and leverage the first mover advantage of the platform.

Following are some good references for Palm Pre development:

http://developer.palm.com/

http://www.weboshelp.net/webos-mojo-development-resources

Posted by Posted by Brijesh Patel under Filed under Code Comments No Comments »

19th Aug 2009

How to call procedure from another procedure or Use the data of dynamic sqlserver query in procedure

Today I will explain very small but very useful feature which I have used in the past for the procedures. When I was new to SQL Server I was facing many problems and this was one of them.

We all know user defined functions has limitations that we can not use #temp table or table variables in UDF. Because of that we can not get the data from another function in the UDF.

So to overcome this problem, we can create the procedure in which we get data from another procedure for further manipulation. Question is how to get data from another procedure? You will get the answer of this question in this post.

e.g., suppose procedure ReturnStudentDetail returns the table with two fields “Name” and “City” so how can you get that table in another procedure for further manipulation.

– Create Table

Create table #StudentDetail

(Name varchar (50), City varchar (100))

– Below code will give you data in the procedure

Insert into #StudentDetail

Exec ReturnStudentDetail

This syntax works only if we use create table. You can also use dynamic sqlserver query output for inserting data in #temp table.

– Create Table

Create table #StudentDetail

(Name varchar (50), City varchar (100))

Declare @sql as varchar (500)

Set @sql = ‘Select Name, City from tbl_StudentDetail where ……..’

– Below code will give you data in table

Insert into #StudentDetail

Exec (@sql)

So, this is how you can get the data from another procedure or Dynamic sqlserver query output in Table. Basic thing is whatever the structure of data being returned, you have to create table on basis of that and use that table to get data from procedure or dynamic sqlserver query.

I hope this feature is useful for you in future. Let me know if you find any better way to achieve this.

Posted by Posted by kuldip.bhatt under Filed under SQL Server Comments No Comments »

13th Aug 2009

Run SWF file in Salesforce Environment

For all the developers who are just starting development in Salesforce may find this article useful. I am going to tell you how you can run an SWF file in Salesforce.

First of all add a reference to the Salesforce namespace to  mx:Application tag and create a connection to the Salesforce.com server.

Eg.

<mx:Application xmls:mx=”http://www.adobe.com/2006/mxml”    xmls:salesforce=”com.salesforce.*” layout = “absolute”/>

<salesforce:Connection id=”apex”/>

The Connection object is already created, so to activate it,Prepare a LoginRequest object by populating the username and password fields. We have to define Callback function(loginResult) that will be fired off when the login response from the Salesforce.com server is received.

Eg.

private function login():void

{

var lr:LoginRequest = new LoginRequest;

lr.username = username.txt;

lr.password = password.txt;

//  lr.server_url = Application.application.parameters.server_url;

// lr.session_id = Application.application.parameters.session_id;

lr.callback = new AsyncResponder(loginResult);

apex.login(lr);

}

No need to give lr.session_id and lr.server_url when running application on local machine.

Deployment

We have three choices to deploy our application.

  1. Deploy it to own server.

  2. Deploy it on Salesforce Environment as an S-Control.

  3. Compile application as an Adobe AIR application and use the new runtime to use the application on the desktop without an application or Web-Server.

Deploy application on Salesforce Environment as an S-Control

To embed the Flex application as an S-Control , compile application for use in Salesforce by modifying the LoginRequest object in code to use the lr.server_url and lr.session_id arguments instead of lr.username and lr.password.

Now log in to Developer account of Salesforce.com and perform following steps.

  1. Click on Setup.

  2. Expand the Develop menu and create S-Control.

  3. Create a new one and give it memorable label and name.

  4. The type will be HTML

  5. In the filename field, browse and select the swf file.

  6. In the content area wirte the following code.

<embed src=”{!Scontrol.JavaArchive}” play=”true”   bgcolor=”#f3f3ec”  width=”100%” height=”100%” name=”FlexSalesforce”  Align=”middle”  flashvars=”session_id={!API.Session_ID}& server_url=    {!API.Partner_Server_URL_90}” loop=”false”allowScriptAccess=”always” type=”application/x-shockwave-flash”  pluginspage=”http://www.adobe.com/go/getflashplayer”</embed>

Here there are three Salesforce.com variables.

  1. Scontrol JavaArchive.

  2. API.Session_ID.

  3. API.Partner_Server_URL_90.

The last two are passed into the SWF when it loads in the browser. These maintain session state. So no need to login while running SWF file.

Now create Tab to house S-Control just created. Create a New Web-Tab with type of Custom S-Control. In step three , Select the S-Control just created to be the content on that tab. Click next through steps four and five. A new tab appear on the top of the screen.

Click on the tab. SWF file will run without required login details.

I hope you found this article useful. Let me know if there are any better ways to do the same thing.

Posted by Posted by nishant.shah under Filed under Flex, salesforce Comments No Comments »

13th Aug 2009

How to perform stress testing in QTP

1. Record the script which you want to perform for stress testing.

For Example:  if you want to add 1000 records then just record add functionality  script.

2. Now just add a loop for that script which contains add record functionality. See below example

For i=0 to 1000

Put your add record script code here. It will repeat the add record loop till 1000 entries will be done.You can insert  1000 records using For.. Next loop.You can also insert more than 1000 or more.Just change your for loop condition for that.

Next will increase your loop counter

Next

Below code is a full example of the stress testing:

For i=0 to 1000

Below code will insert first name jigar. For unique name you can pass value of  i so it will insert unique name each time.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_Name”).Set “Jigar” & i

Below code will enter address in the address field.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_Address”).Set “Surat”

Below code will enter mobile number  in the mobile number field.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_No”).Set “9992426690″

Below is code to save the details

Browser(”PMS”).Page(”PMS_3″).Link(”btn_save”).Click

Next

This is a script to add 1000 records.

Posted by Posted by mehul.brahmbhatt under Filed under Uncategorized Comments No Comments »