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:
- the post request must done via ajax
- the result if meet new error condition must plain json, client knows display popup.
- 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!
- create webservice accepts username / password , returns json success / error
- create ajax based tapestry login page calls webservice in it's onvalidate() event
- re-use webservice non-tapestry apps
- if webservice part of tapestry app, might call java loginservice directly in tapestry app instead of going through webservice wrapper.
Comments
Post a Comment