Differences between revisions 1 and 2
Revision 1 as of 2009-11-05 08:41:01
Size: 2165
Comment:
Revision 2 as of 2009-11-10 08:34:24
Size: 2167
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:

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.

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