Uploaded image for project: 'Spring Web Flow'
  1. Spring Web Flow
  2. SWF-1518

view-state "redirect" is has "true" semantics by default, and not "false" semantics as specified by documentation

    XMLWordPrintable

    Details

      Description

      The SWF 2.0 schema says that on a view-state the redirect attribute is "false" by default.
      This is true in terms of code, to that extend that when not specified the redirect on the ViewState class is "null".
      An null will be translated to false when the value is retrieved, at least using the getter:

      public boolean getRedirect() {
      	return (redirect != null) ? redirect.booleanValue() : false;
      }
      

      However, on the ViewState class the doEnter method calls shouldRedirect to check a redirect should be done, and performs an additional null check:

      private boolean shouldRedirect(RequestControlContext context) {
      	if (redirect != null) {
      		return redirect.booleanValue();
      	}
      	if (context.getExternalContext().isAjaxRequest() && context.getEmbeddedMode()) {
      		return false;
      	}
      	return context.getRedirectOnPause();
      }
      

      Hence, when you don't specify redirect (value is null) in a normal flow situation (no ajax & not embedded) it will depend on the flow context call:

      public boolean getRedirectOnPause() {
      	if (!getExternalContext().isResponseAllowed()) {
      		return true;
      	}
      	Boolean redirectOnPause = flowExecution.getAttributes().getBoolean("alwaysRedirectOnPause");
      	return redirectOnPause != null ? redirectOnPause.booleanValue() : false;
      }
      

      "flowExecution.getAttributes().getBoolean("alwaysRedirectOnPause");" will return true unless you specified the following in your configuration:

      <flow:execution-attributes>
      		<flow:alwaysRedirectOnPause value="false"/>
      </flow:execution-attributes>
      

      ==> the clue is that by default, when you don't specify redirect, there IS a flow execution redirect
      before rendering. The getRedirect() in the ViewState is also nowhere used.

      Suggestion: maintain the 3 states, unspecified, true and false.
      When unspecified fall back to the behaviour as is (check ajax and embedded, then check flow execution attribute).
      When true, perform execution redirect, when false not.
      Adjust documentation in schema accordingly, that when left unspecified the behaviour is like this instead.

        Attachments

          Activity

            People

            Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            koen.serneels Koen Serneels
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated: