Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaplerResponse.forward behaves differently than expected. #191

Open
jtnord opened this issue Jun 17, 2020 · 0 comments
Open

StaplerResponse.forward behaves differently than expected. #191

jtnord opened this issue Jun 17, 2020 · 0 comments

Comments

@jtnord
Copy link
Member

jtnord commented Jun 17, 2020

in the context of Jenkins I had a method being called by Stapler that I was forwarding on to another view by calling response.forward(this, "feedback", request)

However in doing that the breadcrumb bar in Jenkins broke.
This seems to caused by ResponseImpl.forward calling stapler.invoke which sets an empty AncestorList.
Because the ancestorList is empty the breadCrumbs are also empty.

if I manually navigated to the path ezposed by this and then added "/feedback" to the path the breadcrumbs and hence the ancestor list is correctly computed and shown.

It is suprising to me that forward takes an Object and a relative "view" but using anything other than the root and a full "path/to/view" causes unexpected behaviour.

potential fix is to instead use something akin to resp.forward(Jenkins.get(), user.getUrl() + "/" + getUrlName() + "/feedback", req); which is ugly.

Also of note that req.getView(this, "theView").forward(req,resp) does work for this use case, so it is unclear why the first method does not work in this case, and I believe that it should.

summary

StaplerResponse.forward(Object it, String url, StaplerRequest request)

behaves differently to

StaplerRequest.getView(Object it, String viewName).forward(StaplerRequest request, StaplerResponse response)

(when given the same object and a path without a slash)

yet reading the javadoc they should be logically identical (and both should have the behaviour of request.getView(...).forward(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant