java - How can I better handle binary ReST resource errors when submitting a form to download those resources? -
i have service generates pdf document via form of gets rest resource based on input parameters. of these entries map request path's , others map optional request arguments such following illustrates rest resource.
/api/invoices/{invoicenumber}?format={format} on form submission rewrite action on form match resource uri. if invoice number not exist resource return 404 or other error code required based on error condition.
i can fix instead setting error message on page, forms target _blank open new window form redisplayed in target window correct error message of course form blank.
i rather prefer document handled via asynchronous ajax request detect , handle error messages/conditions appropriately i'm not sure if possible (with jquery).
i don't think it's possible conditionally open window because have downloaded content parent window @ point. may possible using jquery typically sending content between windows troublesome , fragile.
what instead on form submit
- open new window alternate action, e.g., fileshowaction, restful url passed parameter
- have new window submit url via jquery or form
- if there's error can show error ok or timer close window
option 2
show file in jquery inline dialog iframe
option 3
have initial rest call either return html errors, etc., or redirect file location. there several other alternatives using semantics of rest e.g., using location header.
Comments
Post a Comment