ajax - Tapestry 5 - POST to endpoint on component and get back JSON in one scenario or do redirects in other scenarios -


i adding new requirement legacy tapestry login component show popup if error condition happens on login, without doing page reload.

currently login component uses standard tapestry form submission - i.e. login creds posted server on form submission, login processing done, , based on result tapestry appropriate redirect returning either page class, or page object injected @injectpage has had setup done on - standard tapestry stuff really.

i need leave current logic - i.e. keep tapestry doing redirects currently, need following extras:

  1. the post request must done via ajax
  2. the result if meet new error condition must plain json, client knows display popup.
  3. the login endpoint must able called other browser-based clients know nothing tapestry , vice-versa tapestry. tapestry redirects should work (if possible - how baked server , client-side framework redirects?) sending down of plain json.

i think (1) , (2) pretty straightforward achieve using tapestry zones, struggling see how (3) fits in. can tapestry support providing http(s) api, callable via ajax, provides redirects plain-old json responses on type of web client? suspect if possible there pattern doing it, can't find docs or examples anywhere, because of time people don't use non-tapestry rendered clients tapestry ends.

if turn out do-able, foresee sea of bad hacks , pitfalls if don't ask community advice , wade in myself, pointers appreciated!

  1. create webservice accepts username / password , returns json success / error
  2. create ajax based tapestry login page calls webservice in it's onvalidate() event
  3. re-use webservice non-tapestry apps
  4. if webservice part of tapestry app, might call java loginservice directly in tapestry app instead of going through webservice wrapper.

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -