Streaming API Using JQuery – Salesforce

Author posted by Jitendra on Posted on under category Categories Tech Tips and tagged as Tags , with 15 Comments on Streaming API Using JQuery – Salesforce

Tutorial of Streaming API in Salesforce with Source code and Demo Video – Implementation of Bayeux protocol and CometD using JQuery and JSON

Push technology is a model of Internet-based communication in which information transfer is initiated from a server to the client. Also called the publish/subscribe model, this type of communication is the opposite of pull technology in which a request for information is made from a client to the server. The information that’s sent by the server is typically specified in advance. When using Streaming API, you specify the information the client receives by creating a PushTopic. The client then subscribes to the PushTopic channel to be notified of events that match the PushTopic criteria.

In push technology, the server pushes out information to the client after the client has subscribed to a channel of information. In order for the client to receive the information, the client must maintain a connection to the server. Streaming API uses the Bayeux protocol and CometD, so the client to server connection is maintained through long polling.

The Bayeux protocol and CometD both use long polling.

  1. Bayeux is a protocol for transporting asynchronous messages, primarily over HTTP.
  2. CometD is a scalable HTTP-based event routing bus that uses an AJAX push technology pattern known as Comet. It implements the Bayeux protocol.

There is nice jQuery plugin available on web which implements Bayeux protocol and CometD.

Navigate here for Salesforce documentation for Streaming API.

Common Terms used in Streaming API:

  • Event : Either the creation of a record or the update of a record. Each event may trigger a notification.
  • Notification : A message in response to an event. The notification is sent to a channel to which one or more clients are subscribed.
  • PushTopic : A record that you create. The essential element of a PushTopic is the SOQL query. The PushTopic defines a Streaming API channel.

Example used in this article :

I want notifications about all opportunity whose status is won.
First step to implement any streaming API is to create the Push Topic, which is going to subscribed by all the clients.

Create PushTopic:

To create PushTopic, we will need the developer console of the Salesforce and assume that the name of the topic is “WonOpportunity”.

PushTopic pushTopic = new PushTopic();
pushTopic.ApiVersion = 23.0;
pushTopic.Name = 'WonOpportunity';
pushTopic.Description = 'Notify if the Opportunity won';
pushTopic.NotifyForOperations = 'All';
pushTopic.NotifyForFields = 'Referenced';
pushtopic.Query = 'Select o.OwnerId, o.Name, o.IsWon, o.Id, o.Amount From Opportunity o WHERE o.IsWon = true';
insert pushTopic;
System.debug('Created new PushTopic: '+ pushTopic.Id);
Salesforce Streaming API - Create Push topic
Salesforce Streaming API - Create Push topic

Continue reading “Streaming API Using JQuery – Salesforce”

Handling Colon in Element ID in JQuery – Visualforce problem

Resolving the JQuery error when the Element ID contains colon with Live Demo

Today i came across very known problem of jQuery and thought of sharing same with everyone. In Salesforce the element id is in the format of “j_id0:j_id3:j_id4:c_txt“. In previous post we have already discussed about getting the elementId in Visualforce.
When i tried to find the element in JQuery like $(‘#j_id0:j_id3:j_id4:c_txt’), i was getting the error on JavaScript console of the browser. After few searches, i got to know that this is known problem and faced by many of the developers.

Live Demo

Continue reading “Handling Colon in Element ID in JQuery – Visualforce problem”

Create Forum inside WordPress blog using Mingle Forum Plugin

Tutorial of How to create Forum inside Wordpress blog using Mingle Forum Plugin

This was the requirement of one of my friend who needed integration of forum with wordpress blog. All the users of wordpress should be able to login into the forum. It was the good idea but normally i have not seen this type of functionality. Then after searching i came across one powerful forum plugin for the wordpress named “Mingle Forum for the wordpress“.

To start with it install the “Mingle Forum” plugin and activate it. Continue reading “Create Forum inside WordPress blog using Mingle Forum Plugin”

CSS – label control ignores the width style

Author posted by Jitendra on Posted on under category Categories HTML, Tech Tips and tagged as Tags with Leave a comment on CSS – label control ignores the width style

CSS – label control ignores the width attribute in style

Label tag does not work with css attribute “width” on some browsers like Chrome and Mozilla.

Simplest solution is :
before applying css for width, make sure “float:left” is written for label control.

Label elements are in-line style elements, so technically Chrome and Firefox are interpreting the CSS properly by not obeying my width declaration. In-line elements do not accept width attributes. The workaround is to force the label element to become a block level element by floating it.

 

Sort comment in reverse order – WordPress

Author posted by Jitendra on Posted on under category Categories Tech Tips, Web Technology and tagged as Tags with Leave a comment on Sort comment in reverse order – WordPress

PHP code to sort the comment in WordPress blog in reverse order

In many cases the blogger may want to sort the comment of there WordPress blog by latest comment at top, like me.

Instead of installing any plugin, i have done following code changes in “comments.php“. Continue reading “Sort comment in reverse order – WordPress”

SAP Security Interview Questions, Tips and Tricks

Author posted by Santosh Karemore on Posted on under category Categories SAP, Tech Tips and tagged as Tags with 5 Comments on SAP Security Interview Questions, Tips and Tricks

Important Must read Interview Questions of SAP Security, Tips and Tricks

1 .  How many fields can be present in one Authorization object?
Ans : 10 fields.


2 .  Which Authorization Objects are Checked in Role Maintenance ?
Ans:
The role maintenance functions (and the profile generator) check the following authorization objects.
Continue reading “SAP Security Interview Questions, Tips and Tricks”

microsot Excel – Change content of alternate cell on change of the cell value using macros

Using VBA script to change the content of alternate column on the basis of value changed in other column of excel sheet

Microsoft excel is very powerful tool to work on the related data. This time i needed a unique functionality in excel sheet and wanted to share with you all. So to create the macro enabled excel sheet, while saving file in file types, select the micro enabled workbook. In Microsoft Excel 2010 the extension of such type of file is “xlsm”.

Requirement:

on changing of auto complete column, a message box should appear and after clicking on button, the adjacent cell value should get changed as shown in below image:

Change content of alternate cell on change of the cell value using macros
Change content of alternate cell on change of the cell value using macros

Continue reading “microsot Excel – Change content of alternate cell on change of the cell value using macros”

Uninstall plugin from Eclipse

Author posted by Jitendra on Posted on under category Categories Tech Tips and tagged as Tags with Leave a comment on Uninstall plugin from Eclipse

Tutorial of how to Uninstall plugin from Eclipse with screen shots of the steps

Follow below steps to uninstall the plugin from Eclipse:

Open Eclipse and go to Help | About Eclipse

Below window will be opened.

Eclipse Installation details
Eclipse Installation details

Continue reading “Uninstall plugin from Eclipse”

ASP.NET Page Lifecycle

Author posted by Jitendra on Posted on under category Categories ASP.NET, Tech Tips and tagged as Tags with Leave a comment on ASP.NET Page Lifecycle

Tutorial and sample source code on ASP.NET Page Lifecycle

Introduction

Understanding Page lifecycle is very crucial in order to develop ASP.NET applications. Most beginners tend to get confused while dealing with “dynamic controls” and face problems like losing values, state etc on postbacks. Since HTTP is stateless, the nature of web programming is inherently different from windows application development, and the Page lifecycle is one of the primary building blocks while learning ASP.NET. The sequence of events, especially while working with MasterPages in ASP.NET 2.0, has become slightly more complex and this article is aims to shed some light on these events by explaining the order and importance of each event.

Background

Whenever the user requests a particular “.aspx” page in an application, a lot of interesting things happen on the web server where the application is hosted. Understanding this sequence of events will help us to program and respond to events properly and also clear any confusion which generally arises due to the stateless nature of web programming.

The New Compilation Model and the Partial Classes

Each web form in an ASP.NET application derives directly or indirectly from a “System.Web.UI.Page” class. A web form has two components: a code behind file (Default.aspx.cs) which contains the code for the events and other methods related to a Page, and the designer ASPX file(Default.aspx), which contains HTML control declarations and events (in the Visual Studio 2005 Web Application project model, we have a designer class named WebForm.aspx.designer.cs).

In ASP.NET 2.0, we do not need to define the control variables as well as there event handlers in the code behind, thanks to Partial classes. In ASP.NET 1.x, all this code was auto generated and placed in the code behind file under InitializeComponent() section. But in version 2.0, the runtime will create a partial class dynamically from the ASPX page containing all this info and merge it with the code behind partial class. This will help in making the actual code behind class a lot cleaner and more manageable.

Also, this would eliminate the name change related issues which were common in VS 2003 (if we change any control’s ID, it had to be changed everywhere and VS used to modify the code many times). All control related events are defined in the ASPX markup code. So having a single place for controls names and event handlers is cleaner and flexible, whereas the previous VS 2003 model was more “brittle”.

The Page life cycle

It is very important to know that for each request, the Page class is instantiated everytime from “scratch”. Which means that any values or whatever state it had previously will get lost unless we use one of the various state maintainance mechanisms provided by ASP.NET like Application, Session, Cache variables or Cookies.

Side Note: View state in ASP.NET 2.0 has changed and now comprises of two parts: Control State and View state. Refer this article for details.

Below is the sequence of events which fire up sequentially with explanation on the relative importance with respect to web programming in code behind:

1. PreInit()

In this Page level event, all controls created during design time are initialized with their default values. For e.g., if you have a TextBox control with Text property = “ShivaSoft”, it would be set by now. We can create dynamic controls here.

This event occurs only for the Page class and “UserControls / MasterPages do not have this method to override“.

Sample code where you can override this method :

Syntax :

    protected override void OnPreInit(EventArgs e)
    {
        //custom code
        base.OnPreInit(e);
    }

Note that PreInit() is the only event where we can set themes programmatically.

Continue reading “ASP.NET Page Lifecycle”

Eclipse – How to upgrade from Galileo (3.5) to Helios (3.6)

Author posted by Jitendra on Posted on under category Categories Tech Tips and tagged as Tags with 1 Comment on Eclipse – How to upgrade from Galileo (3.5) to Helios (3.6)

Eclipse – How to upgrade from Galileo (3.5) to Helios (3.6)

I needed to work on Tomcat 7 and at that time i was using Eclipse Galileo. So i needed to upgrade Eclipse Galileo to Helios any how to get work done.

So below is the steps which i used to upgrade my eclipse.

To upgrade installed software, do the following:

  1. Help > Check for Updates.
  2. If updates are found, proceed through the install wizard and click Finish at the end.
  3. If you are upgrading the platform itself, when you are prompted to restart it is strongly recommended to do so. A restart many not be required when updating other features, but always select to restart if you are unsure.

Note, to upgrade from Galileo(3.5) to Helios (3.6), you first need to add the Helios software repository as follows:

  1. Window > Preferences > Install/Update > Available Software Sites.
  2. Click “Add”.
  3. Enter
  4. http://download.eclipse.org/releases/helios
  5. Click “Ok”.