Frage

I have an URL which shows me a coupon form based on id:

GET /coupon/:couponId

All the coupon forms are different and submit different POST params to:

POST /saveCoupon/:id

I want to have a convenient way of debugging my coupons and be able to have a way of viewing actual POST params submitted.

I've made a controller on URL POST /outputPOST/saveCoupon/:id which saves nothing, but prints to browser POST params received.

Now I want to have an URL like GET /changeActionUrl/coupon/:couponId which calls GET /coupon/:couponId and then substitutes form's action URL POST /saveCoupon/:id with POST /outputPOST/saveCoupon/:id .

In other words I want to do something like:

Result.getHtml().replace("/saveCoupon/","/outputPOST/saveCoupon/");

With this I can easily debug my coupons just by adding "/outputPOST" in the browser.

War es hilfreich?

Lösung

You could just use a bookmarklet and javascript to replace all of the forms' action attributes. That way your developer can do it with one click instead of changing urls.

Something like this will prefix all form actions on the page with "/outputPOST".

javascript:(function(){var forms=document.getElementsByTagName('FORM');for(i=0;i<forms.length;++i){forms[i].setAttribute('action','/outputPOST'+forms[i].getAttribute('action'));}})();

Andere Tipps

I don't understand, at least not everything ;)

In general you can debug every piece of Play app using debugger (check for your favorite IDE tips how to do that) - this will be always better, faster, etc etc, than modifying code only for checking incoming values.

I.e. Idea 13+ with Play support allows for debbuging like a dream!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top