Executing Javascript from Server Side

As of PrimeFaces 2.x, oncomplete callback can be used to execute javascript when an ajax request completes like;


<p:commandButton value="Submit" oncomplete="alert('done')" />

<p:ajax oncomplete="alert('done')" />

In case where you need to add conditional logic to your oncomplete that is done via RequestContext callback parameters, like hiding/showing dialog in case of validation errors(see demo).

With 3.0.M2, there is a new handy feature coming which is executing javascript from your backing beans;


RequestContext context = RequestContext.getCurrentInstance();

context.execute("alert('hi')");

context.execute("mydialog.hide()");

About these ads

7 Responses to Executing Javascript from Server Side

  1. yigitdarcin says:

    waiting this to apply our project caga.

    thx kib byez…

  2. Luuzz says:

    Fantastic !!
    When will the M2 be available ?

  3. Daniel says:

    Wow!!!

    Great Feature!

  4. halil says:

    demo is not working on ff4, not shaking or fading

    but it works on real showcase

  5. rodakr says:

    interesting!
    conditional javascript from server side :-)

  6. rene says:

    Cool, reminds me of GWT ;) Don’t use it too much without a compiler

  7. RTC says:

    M2 Version ne zaman çıkabilir?

Follow

Get every new post delivered to your Inbox.

Join 106 other followers

%d bloggers like this: