Using Trinidad with Spring Web Flow
Coverage of Trinidad UI Component widgets using the example of tr:inputDate
When using Trinidad in Spring Web Flow based applications developers unfortunately run into problems when using UI components like tr:inputDate.
Actual State
while loading the calendar popup of trinidad SpringWebFlow's controller generates a request uri like this:
<myapp>/someflow?execution=e2s2& _t=fred&_red=cd&value=1256825236538&loc=de-DE&enc=UTF-8
instead of
<myapp>/faces/ADFv?_t=fred&_red=cd&value=1256825236538&loc=d e-DE&enc=UTF-8
Workaraound
So the solution is a servlet filter that intercepts requests like this and redirects to the faces servlet. Yes, indeed this isn't very nice but it works:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestURI = httpRequest.getRequestURI();
String queryString = httpRequest.getQueryString();
int idx = 0;
if ( (idx = StringUtils.indexOf(queryString, this.searchString)) >= 0 &&
requestURI.contains(this.facesServletMapping) == false ) {
String forwardUri = httpRequest.getContextPath();
forwardUri = forwardUri + this.facesServletMapping + "/__ADFv__?" + queryString.substring(idx+1);
((HttpServletResponse) response).sendRedirect(forwardUri);
} else {
chain.doFilter(request, response);
}
} else {
chain.doFilter(request, response);
}
}
public void init(FilterConfig config) throws ServletException {
this.facesServletMapping = StringUtils.defaultIfEmpty(config.getInitParameter("facesServletMapping"), "/faces");
this.searchString = StringUtils.defaultIfEmpty(config.getInitParameter("searchString"), "&_t=fred&_red");
}As an alternative one could replace the single searchString filter param with a comma separated list of search strings.