Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Next I'll cover the proposals to handle the Ajax request and response on the server-side.

Anchor
proposals
proposals
Proposals

Anchor
page-methods
page-methods
1. Ajax aware Page methods

...

  • A control can only have a single listener defined. How will a control handle multiple incoming events? For example a field might handle two Ajax events, "onblur" for validation purposes, and "onkeypress" for auto-completion. The Event object passed into the listener could be inspected, but this leads to if-else logic. This brings up the idea of having multiple listeners per control.
    • Pro: Each listener could be registered for a specific event, and will only be triggered for Ajax requests of that event type.
    • Con: Having multiple listeners per control could increase the conceptual complexity and could lead to an increase in maintenance. For example, if the client-side code neglects to pass the event parameter, no listener will be invoked. The user will now have to deal with whether the control ID or event request parameter or both are missing.

Anchor
ajax-behaviors
ajax-behaviors
3. Ajax Behaviors

Behaviors is a concept borrowed from Wicket and JSF. A behavior is attached to a Control and will be notified by the Control for specific events such as onInit, onProcess, onRender, getHeadElements. A behavior can also act as a listener and receive events, just like a Control does.

...

Anchor
which
which
Which one?

I'm leaning towards introducing both Page methods and Ajax Behaviors. The simplicity of Page methods combined with the flexibility of Ajax Behaviors seems like a good choice.