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:

instead of

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.

Trinidad_and_SpringWebFlow (last edited 2009-11-10 08:34:24 by MarkusSchmitt)