jakartaee / faces

Jakarta Faces
Other
109 stars 55 forks source link

Validation error removes all url parameters #1175

Open eclipse-faces-bot opened 11 years ago

eclipse-faces-bot commented 11 years ago

This bug was copied from Mojarra issue tracker. See details here: http://java.net/jira/browse/JAVASERVERFACES-1653

When page has some url parameter(s) after server-side validation error or by default navigation JSF navigates to the page with the same viewId but without url parameters.

IMHO the problem is the POST method submits the form to viewId's url only instead of using url with the parameters as original url has.

This issue makes problems with bookmarking such views with params after handling some action(minor problem) and generating proper response after action handling based on this parameters(major problem) .

P.S. Also this issue has another side effect. When handling some action the url parameters are unavailable.


I found some easy workaround for this problem.

I just slightly extend standard ViewHandler to add the queryString to the action url:

public class UrlWorkaroundMultiViewHandler extends MultiViewHandler {

@Override public String getActionURL(FacesContext context, String viewId) {

String result = super.getActionURL(context, viewId); String queryString = ((HttpServletRequest) context.getExternalContext() .getRequest()).getQueryString(); if (queryString != null)

{ result += "?" + queryString; }

return result;

} }

and register it in the faces-config.xml

my.workaround.UrlWorkaroundMultiViewHandler

I'm not sure this will work for any cases and for all servlet containers. Also I'm not sure about possible side effects. I did check it with Jetty.


UPDATE: I found that we have not add params when we handle new url. So I modify my workaround code to handle more cases:

@Override public String getActionURL(FacesContext context, String viewId) {

String result = super.getActionURL(context, viewId);

HttpServletRequest request = ((HttpServletRequest) context .getExternalContext().getRequest());

if (viewId.equals(request.getServletPath())) { //Do it just if we are on the same page String qs = request.getQueryString(); if (qs != null)

{ result += "?" + qs; }

}

return result;

}

Conclusion: I believe that any valid url should be preserved as is(including query parameters). Even we do not use its url parmas on our page.

Affected Versions

[2.2 Sprint 13]

eclipse-faces-bot commented 5 years ago
eclipse-faces-bot commented 11 years ago

@glassfishrobot Commented Reported by a_ilyin

eclipse-faces-bot commented 11 years ago

@glassfishrobot Commented @arjantijms said: This looks like a duplicate of #1163.

eclipse-faces-bot commented 10 years ago

@glassfishrobot Commented @edburns said: Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

eclipse-faces-bot commented 10 years ago

@glassfishrobot Commented @manfredriem said: Setting priority to Minor

eclipse-faces-bot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1175