Osama's Weblog

The place where you get updated!
  • rss
  • Home
  • Who am I?
  • RSS Feeds

Using apex:actionSupport in VisualForce Pages

Osama | November 19, 2009

//
//

Most of the times there is a requirement to call a method on different events of a webpage component. for example; ‘onchange’ event of a text box. This is done in html pages by javaScript.

In Visualforce pages, there is a requirement sometimes to call a method on some event which is placed in the controller of the page. To do it, I have been using the actionFunction apex component and the call the method through javaScript. Below is the code below what I have been doing since few days:

<apex:page controller=”TestClass”>

<apex:form>

<script>

func scr(){

acFunc();

}

</script>

<apex:actionFunction name=”acFunc” action=”{!funct}”/>

<apex:inputText id=”txt” value=”{!textBox}” onclick=”scr();”/>

</apex:form>

</apex:page>

———-Controller————
public class TestClass()
{
public String textBox; {set;get;}
public void funct()
{
textBox = ‘This text is displayed after reRendeing’;
}
}

But, today I found another apex component, actionSupport,  which can do the same thign without involving javaScript.

here is the code below showing the working of actionSupport component.

<apex:page controller=”TestClass”>

<apex:form>

<apex:inputText id=”txt” value=”{!textBox}”>

<apex:actionSupport action=”{!funct}” event=”onclick” >

</apex:inputText>

</apex:form>

</apex:page>

———-Controller————
public class TestClass()
{
public String textBox; {set;get;}
public void funct()
{
textBox = ‘This text is displayed after reRendering’;
}
}

Actually, javaScript does get invoked but using actionSupport but its on server side. I find it easy to call an apex function this way. But it depends upon the requirements provided. Sometimes we cant afford too much server side interaction. That was it for actionSupport. Hope you have found it helpful as I did find it efficient for my work.

Feel free to ask questions.

  • Share/Bookmark
Comments
No Comments »
Categories
APEX, VisualForce
Tags
actionFunction, actionSupport, APEX, controller, JavaScript, VisualForce
Comments rss Comments rss
Trackback Trackback

Parallel Programming in .NET 4.0

Osama | November 9, 2009

Now a days, many of us know what parallel computing is. As the CPU clock cycle was increasing day by day, the problem of increasing power consumption was also arousing. The solution was to reduce the CPU clock cycle and multiple cores in to increase the processing power. Many computers now are multi core or many core systems. Dual Core and Quad core systems are the examples. Systems with more than previously mentioned cores are expected to come in near future as the demand of processing power is increasing.

We do have multi core systems but most of the programs that we use are not capable of utilize and exploit the power of multi core systems. Most of these software are based up on serialization. To exploit the power of multi core systems, software developers can parallelize their code to distribute work across multiple processors. Microsoft, which has always simplified programming for the developers, has also stepped up into parallel programming to make the programs utilize the power of multi core systems. In the new Microsoft Visual Studio 2010 and .NET Framework 4 Beta 2, there are some new features related to parallel programming:

  • support for parallel programming with a new runtime
  • new class library types, and diagnostic tools.

These features provides a friendly and easy way to develop efficient and scalable parallel applications without getting into low level programming and directly work with threads or the thread pool. The image below, provides a high level overview of the parallel programming architecture in .NET Framework 4 Beta 2:

The supports which is provided in Microsoft Visual Studio 2010 and .NET framework 4 Beta 2 for parallel programming can be categorized into these four areas

Task Parallel Library Overview:

The Task Parallel Library (TPL) is a set of public types and APIs in the System.Threading and System.Threading.Tasks namespaces in the .NET Framework version 4. These types rely on a task scheduler that is integrated with the .NET ThreadPool. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications.It includes parallel implementations of for and foreach loops. It enables the developer to define concurrent, asynchronous tasks without having to work with threads, locks, or the thread pool.

Parallel LINQ (PLINQ):

PLINQ is a parallel implementation of LINQ to Objects that improvises the performance in many scenarios. PLINQ implements the full set of LINQ standard query operators as extension methods for the T:System.Linq namespace and has additional operators for parallel operations. PLINQ combines the simplicity and readability of LINQ syntax with the power of parallel programming

Data Structures for Parallel Programming:

The .NET Framework version 4 introduces several new types that are useful in parallel programming, including a set of concurrent collection classes, lightweight synchronization primitives, and types for lazy initialization. You can use these types with any multithreaded application code, including the Task Parallel Library and PLINQ.

Parallel Diagnostic Tools:

Includes debugger windows for tasks and parallel stacks, and concurrency views in the Visual Studio Team System Profiler that you can use to debug and to tune the performance of parallel code.

 

Sources: MSDN

  • Share/Bookmark
Comments
No Comments »
Categories
.NET
Tags
.NET 4.0 beta, Parallel Programming, Visual Studio
Comments rss Comments rss
Trackback Trackback

Accessing APEX variables in JavaScript

Osama | November 3, 2009

It is pretty useful to access variables, defined in Apex controller, in JavaScript. It has been very useful atleast for me. Its efficient and saves alot of time.

Here is the code below showing the use of apex variables in javascript.

 

<apex:page cache=”false” controller=”myController”>

<script>

alert(‘{!myVariable}’);

</script>

</apex:page>

public class myController

{

public String myVariable=’I am a Variable’ {set;get;}

}

Simple!

Feel free to ask any questions

  • Share/Bookmark
Comments
No Comments »
Categories
APEX, VisualForce
Tags
APEX, Apex variable, JavaScript, VisualForce
Comments rss Comments rss
Trackback Trackback

My status

Categories

  • .NET
  • APEX
  • consulting
  • General
  • Oracle CRM on Demand
  • salesforce
  • Uncategorized
  • VisualForce

MM Did You Know?

Charlie Chaplin once won third prize in a Charlie Chaplin look-alike contest.
Plugin by mmilan

Its all about cloud

Salesforce

.NET .NET 4.0 beta actionFunction actionSupport administrator android APEX Apex variable API button certification cloud computing consulting controller custom DoDirectPayment force.com GET goggles google html images input inputField JavaScript jquery master-detail matcher Parallel Programming parameters pattern paypal query string REGEX regular expression salesforce search url variable Visual Force VisualForce Visual Studio vmware web service XML PARSING DOM SAX STAX

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

My Tweets

Error: Please make sure the Twitter account is public.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox