endless loop in apex

This is part of my antipattern collection

I just stumbled across a new way how to create endless loops in Apex. I discovered it in some hidden corner in an application that I’m currently enhancing.

  1. Create a select list item
  2. Create a dynamic action that triggers “onChange”.
    The true action should be a javascript action that does: doSubmit(“someValue”);
  3. Add a page branch that redirects to the same page

So far no real problem.

4. Now change the true action to fire on page load.

The first load of the page is fine. But as soon as you click on the select list item and change the current value, the page starts an endless cycle of

“onChange event”

⇒ “javascript true action”

⇒ “submit processing”

⇒ “branching”

⇒ “page load”

⇒ “javascript true action”

⇒ “submit processing”

⇒ “branching”

⇒ “page load”

⇒ ….

Fortunatly you can simply kill the browser tab to stop it. 🙂

What do we learn from that?

Dynamic actions that fire on page load are EVIL!

One thought on “endless loop in apex

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.