Hello All,
Using source page is good idea when we want to redirect to the "source" page
from what incorrect data was sent.
What if we want that page (where user is redirected if there were any errors)
be always the same?
Example:
User registration scenario. User registration form is on different pages of the
site (there is some quick registration form on each page if user was not signed
up yet and there is a dedicated registration page with advanced options).
There are such relevant actions:
// Used to display advanced registration page
@DontValidate
public Resolution signup() {
return new ForwardResolution("/WEB-INF/jsp/user/signup.jsp");
}
// Actually creates user, used as "target" if html forms
// data to this action could be sent from different pages
// the advanced sign up page that is rendered by signup() method above
// or many other pages where simple registration form is placed
public Resolution create() {
evologService.createUser(user.getUsername(), user.getPassword(),
user.getEmail());
return comfirmation();
}
What I need:
Every time when create() has errors (doesn't meter if data was sent from either
advanced registration form on dedicated page or simple registration form on any
other page) then Resolution returned from signup() method should be used in
ActionBeanContext.getSourcePageResolution();
I tried to override ActionBeanContext's getSourcePageResolution() method like
this:
public Resolution getSourcePageResolution() {
// default source page resolution (that could be set in ActionBean)
// overrides source page resolution created from request source page
if (null != defaultSourcePageResolution)
return defaultSourcePageResolution;
return super.getSourcePageResolution();
}
and set this "defaultSourcePageresolution" to CustomActionBeanContext in create
() method that could solve the problem, but it doesn't because
"defaultSourcePageresolution" will be set when validation will be already done
DispatcherServlet firstly calls and only after that if there where no
validation errors invokeEventHandler(ctx) and because "create()" event will
never be called and it will be called after validation, overriding
getSourcePageresolution() has no effect :(
Question: Is there any good/suitable way to make "redirect on validation error
(s) page" be always the same for particular event, like create() event in my
example?
I would like to specify such "static" error pages (using resolutions returned
from other events) every time for any event that could produce validation errors
and don't use "_sourcePage" http param at all, until i will *really* need to
have errors from the same create() event to be displayed on different pages
that were the source of validation error(s) and specify _sourcePage explicitly
not only for links but even as hidden input in forms.
I really think that "_sourcePage" http param should be optional not only in
links, like it was done in Stripes 1.5, but in forms also and "redirect on
error" page should specified on action that could produce validation error,
maybe as annotation with source page string path or resolution as value and
"_sourcePage" http param should be used as an option to override behavior
described above.
Is it possible now to have such behavior ? If not then how to make Stripes work
like that in easy way?
Then even if somebody will open (on any reason) html form's action url like
"http://somedomain.tld/somecontext/user/create" in browser without adding
"_sourcePage" param to url, user will be redirected to "http://somedomain.tld/
somecontext/user/signup" page because create() event "knows" where to redirect
user if validation error occurred.
But you should be always able to override this behavior (if it really needed
for any reason) like this "http://somedomain.tld/somecontext/user/create?
_sourcePage={someHashedOrPlainSourcePage}". The same about hidden inputs in
forms.
I wonder if anyone else wanted such behavior with default error page for events
that could produce errors before, what do you think about this way?
Thanks a lot,
Alex
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users