Press ESC to close

Is Javascript Remoting == ViewStateLess Visualforce ?

Javascript remoting is one of my favourites from Spring’11 release and I’m constantly thinking of making best use of it in Visualforce. I believe remoting is the way to make Visualforce more “viewstate less”, this post shows a POC of a complete functional example of a page that searches and updates accounts using Remoting only i.e no viewstate.
In my previous post about “javascript remoting using jquery tempaltes”, we saw how we use remoting to easily render a salesforce style grid of accounts.
In this post, we will see how we can easily extend the same account grid example, to finally have following features

  • A account search box, that allows user to search for accounts via name. (this search is powered by Javascript Remoting)

  • Account records returned by Javascript remoting search are rendered into a salesforce style pageblocktable, this is done using jquery templates.

  • Have editable PHONE field in the account grid. When user changes any phone number in this grid its updated back on the account record in salesforce (this update is powered by Javascript Remoting)

Side note : This post requires jquery knowledge, its jquery who’s making many big things look trivial in sample code. So if you are not in LOVE with jquery, starting dating her/him

Open-mouthed smile

Where is the code ?

Code for both Apex Controller and Visualforce page is available on If you have any comments/concerns/queries please comment back here on this post.

Remoting in Action !

Searching for accounts

Account updated on blur

So, Javascript Remoting == ViewStateLess VisualForce ?

It would be great if we can go 100% view stateless !!! but as of now, its not 100% possible to go view stateless on all fronts using Javascript Remoting.
The major reason I see is “locale specific formatting and validations”. These validations are done super smartly and silently by visualforce tags like <apex:inputField …/>.  So, you have to be careful, if you are going to deal with fields like Number, Currency and Date fields in visualforce.

But, that doesn’t means we loose heart and can’t do cool things, with HTML 5 “input” tag has gone much smarter then ever before i.e. supporting phone, email etc as type.

Comments (12)

Leave a Reply

%d bloggers like this: