/src/main/resources/template/simple/default-pushbutton-listener.ftl

http://struts2yuiplugin.googlecode.com/ · Freemarker Template · 35 lines · 24 code · 0 blank · 11 comment · 5 complexity · 032ba7fd1351ac57b449bdaf39a28074 MD5 · raw file

  1. <#--
  2. Default listener for the click event for 'pushbuttons'.
  3. Note the implementation is slightly different than an a submit because it doesn't search for a containing form
  4. (A form is used only if explicitly identified by formId)
  5. Parameters:
  6. clickListener name of the listener function
  7. href alternative URL (if not using the form's action)
  8. method http method to use
  9. callback name of the callback function (see YUI Connection Manager)
  10. customCallback if false, the default callback will be included
  11. -->
  12. function ${parameters.clickListener}(e, formId) {
  13. YAHOO.util.Event.preventDefault(e);
  14. <#if parameters.href?exists>
  15. var href='${parameters.href}';
  16. <#else>
  17. var formObject = null;
  18. var href = null;
  19. </#if>
  20. if (formId) {
  21. formObject = document.getElementById(formId);
  22. }
  23. if (formObject != null) {
  24. YAHOO.util.Connect.setForm(formObject);
  25. <#if !parameters.href?exists>
  26. href=formObject.action;
  27. </#if>
  28. }
  29. if (href) {
  30. YAHOO.util.Connect.asyncRequest('${parameters.method}', href, ${parameters.callback});
  31. }
  32. }
  33. <#if !parameters.customCallback>
  34. <#include "/${parameters.templateDir}/simple/default-callback.ftl" />
  35. </#if>