Control flow is currently recalculated for each traversal phase in a template, which can cause templates to break if the traversal depends on data being changed. Consider the following application:

  define page root(){
      if(fooglobal.x == null) {
        form{
          input(fooglobal.x)
          submit action{} {"Save"}
        }
      } 
      else {
        output(fooglobal.x)
      }
  }

  entity Foo{
    x :: URL
  }

  var fooglobal := Foo{ x := null }

Saving the form will produce an error, because the submit action will not be handled when fooglobal.x != null, which becomes true in the store inputs phase (before the handle actions phase). The initial test result (where fooglobal.x == null is true) should be stored and used for each subsequent phase.

Submitted by Danny Groenewegen on 10 December 2010 at 14:21

On 10 December 2010 at 14:22 Danny Groenewegen tagged 1.2.6

On 10 December 2010 at 16:35 Danny Groenewegen commented:

workaround:

Put condition in template var, that way the condition will only be evaluated once, in the initial traversal phase:

define page root(){
  var showform := fooglobal.x == null
  if(showform) {
    form{
      input(fooglobal.x)
      submit action{} {"Save"}
    }
  } 
  else {
    output(fooglobal.x)
  }
}

On 4 January 2011 at 12:56 Danny Groenewegen removed tag 1.2.6

On 4 January 2011 at 12:56 Danny Groenewegen tagged 1.2.7

On 11 February 2011 at 15:50 Danny Groenewegen removed tag 1.2.7

On 11 February 2011 at 15:50 Danny Groenewegen tagged 1.2.8

On 4 June 2011 at 12:43 Danny Groenewegen tagged 1.2.9

On 4 June 2011 at 12:43 Danny Groenewegen removed tag 1.2.8

On 24 February 2012 at 17:02 Danny Groenewegen tagged 1.3.0

On 24 February 2012 at 17:02 Danny Groenewegen removed tag 1.2.9

On 15 January 2013 at 14:25 Eelco Visser tagged confirmed

On 15 January 2013 at 14:25 Eelco Visser removed tag 1.3.0

On 23 October 2015 at 13:14 Danny Groenewegen commented:

fixed, the control flow is now cached so that it doesn’t break after databind phase


On 23 October 2015 at 13:14 Danny Groenewegen closed this issue.

Log in to post comments