How to Dynamically Change actionStatus Content? - Part I

Nowadays many Salesforce developers employ the powerful Visualforce framework to create richer and more complex applications. The framework itself might not as flexible or as elaborate in terms of offerings however combining it with client-side programming features (DOM model and javascript) you actually can do interesting things!

In this article I will show you how you can work around the basic actionStatus limitations and show dynamic content in actionStatus depend on what action is being triggered on the page.

Let's say that we want to create a page with following characteristics:
  • The page filters Accounts records based on Account Type and view the records to user via pageBlockTable
  • One column of the shown table has a link "Action" which when clicked on a controller's method will be called via javascript.
  • Meanwhile, the actionStatus will show a message like: Processing {Account.Name} ... (Neat ehh!). The message can be combined with any HTML code (for each row in the table) to enhance the view of the actionStatus

Now let's look a bit further into what we need to put together in the page to accomplish the above:
  • I will need an InputField component to be hooked up with Account's picklist "Type".
  • Also a commandButton to call a method of the Controller and view the results on the pageBlockTable
  • The pageBlockTable will have Account Name, Type and Action columns. Action column will have a facet in which we will do our trick! The facet should do the following:
  1. It will have a hyperlink which calls a javascript function once clicked on.
  2. Also it will have a hidden div which will contain the HTML template we need to show in actionStatus once the link is clicked on!
But how exactly a javascript function can change the content of start or stop facets of actionStatus and how it will trigger the methods of the Custom Controller?

You will see all these in the next page.

No comments:

Post a Comment