From: Marc P. <ma...@an...> - 2003-08-01 11:14:56
|
I just got, using the latest CVS source: org.webmacro.engine.BuildException: Error parsing template: FileTemplate:xxxxxx (name removed) java.lang.StringIndexOutOfBoundsException: String index out of range: -1 The problem seems to be related to #begin...#end handling, possibly to do with nested directives (#set). If I remove my EXPLICIT #begin...#end it works fine. The line is marked in the template below. I will add a test case for this. #include "includes/header.wmt" <h2>Generator for SQL CREATE TABLE based on Metalizer Schema</h2> <form action="gensql.wmt" method="post"> Schema name: <input name="$Ignition.FormFieldName.schemaName" #if ($Ignition.FieldValue.schemaName) value="$Ignition.FieldValue.schemaName" #end > <input type="submit" value=" Generate "> </form> #if ($Ignition.FieldValue.schemaName) <h3>SQL follows:</h3> #set $schema = $Ignition.getSchema($Ignition.FieldValue.schemaName) <pre> CREATE TABLE tablename ( #set $first = true #foreach $group in $schema.FieldGroups #begin #foreach $fieldName in $schema.getFieldNamesInGroup($group) #begin #set $field = $schema.getField($fieldName) !!!!!!!!!!!! This next line is the problem #if ($first) #begin #set $first = false #end #else #begin , #end $field.Name $field.DataType.Name #end #end ); </pre> #end -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Lane S. <la...@op...> - 2003-08-01 15:02:34
|
what happens when you use {} ? Marc Palmer wrote: > > I just got, using the latest CVS source: > > org.webmacro.engine.BuildException: Error parsing template: > FileTemplate:xxxxxx (name removed) > java.lang.StringIndexOutOfBoundsException: String index out of range: -1 > > The problem seems to be related to #begin...#end handling, possibly to > do with nested directives (#set). > > If I remove my EXPLICIT #begin...#end it works fine. > > The line is marked in the template below. I will add a test case for > this. > > > #include "includes/header.wmt" > > <h2>Generator for SQL CREATE TABLE based on Metalizer Schema</h2> > > <form action="gensql.wmt" method="post"> > Schema name: <input name="$Ignition.FormFieldName.schemaName" > #if ($Ignition.FieldValue.schemaName) > value="$Ignition.FieldValue.schemaName" > #end > >> > <input type="submit" value=" Generate "> > </form> > > #if ($Ignition.FieldValue.schemaName) > <h3>SQL follows:</h3> > > #set $schema = $Ignition.getSchema($Ignition.FieldValue.schemaName) > <pre> > CREATE TABLE tablename ( > > #set $first = true > #foreach $group in $schema.FieldGroups > #begin > #foreach $fieldName in $schema.getFieldNamesInGroup($group) > #begin > #set $field = $schema.getField($fieldName) > !!!!!!!!!!!! This next line is the problem > #if ($first) #begin #set $first = false #end #else #begin , #end > $field.Name $field.DataType.Name > #end > #end > ); > </pre> > > #end > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga |
From: Keats <ke...@ea...> - 2003-08-05 20:08:45
|
Marc, I have isolated this problem and it appears to be a whitespace issue with the in-line explicit #begin. I reduced your test case to the minimal: #if (true) #begin #set $x=0 #end which still gives the error. Adding a second space before the #set (or replacing it with a newline) makes the error go away. Apparently the parser prematurely discards the whitespace that it needs to recognize the next token as a directive. I have made a one-line patch to the ParserBlockBuilder.directiveOK(), line 227, to check for an empty String which seems to fix the problem. All the unit tests still pass, but I guess I'd feel more confortable having Brian bless this before I commit the change. Keats ----- Original Message ----- From: "Marc Palmer" <ma...@an...> To: <web...@li...> Sent: Friday, August 01, 2003 7:12 AM Subject: [Webmacro-devel] Parser error: StringIndexOutOfRange > > I just got, using the latest CVS source: > > org.webmacro.engine.BuildException: Error parsing template: > FileTemplate:xxxxxx (name removed) > java.lang.StringIndexOutOfBoundsException: String index out of range: -1 > > The problem seems to be related to #begin...#end handling, possibly to do > with nested directives (#set). > > If I remove my EXPLICIT #begin...#end it works fine. > > The line is marked in the template below. I will add a test case for this. > > > #include "includes/header.wmt" > > <h2>Generator for SQL CREATE TABLE based on Metalizer Schema</h2> > > <form action="gensql.wmt" method="post"> > Schema name: <input name="$Ignition.FormFieldName.schemaName" > #if ($Ignition.FieldValue.schemaName) > value="$Ignition.FieldValue.schemaName" > #end > > > <input type="submit" value=" Generate "> > </form> > > #if ($Ignition.FieldValue.schemaName) > <h3>SQL follows:</h3> > > #set $schema = $Ignition.getSchema($Ignition.FieldValue.schemaName) > <pre> > CREATE TABLE tablename ( > > #set $first = true > #foreach $group in $schema.FieldGroups > #begin > #foreach $fieldName in $schema.getFieldNamesInGroup($group) > #begin > #set $field = $schema.getField($fieldName) > !!!!!!!!!!!! This next line is the problem > #if ($first) #begin #set $first = false #end #else #begin , #end > $field.Name $field.DataType.Name > #end > #end > ); > </pre> > > #end > |
From: Marc P. <ma...@an...> - 2003-08-06 10:25:16
|
On Tue, 5 Aug 2003 16:06:30 -0400, Keats <ke...@ea...> wrote: > Marc, > > I have isolated this problem and it appears to be a whitespace issue with > the in-line explicit #begin. [snip] > I have made a one-line patch to the ParserBlockBuilder.directiveOK(), > line > 227, to check for an empty String which seems to fix the problem. All > the > unit tests still pass, but I guess I'd feel more confortable having Brian > bless this before I commit the change. Thanks for tracking this down Keats! Brian, is this a go-er? -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Brian G. <br...@qu...> - 2003-08-07 07:56:53
|
>Thanks for tracking this down Keats! > >Brian, is this a go-er? Sort of. The code Keats checked in appears to work around an existing bug in ParserBlockBuilder, but doesn't fix it. It probably won't hurt, but this bug is likely to come up again. -- Brian Goetz Quiotix Corporation br...@qu... Tel: 650-843-1300 Fax: 650-324-8032 http://www.quiotix.com |
From: Marc P. <ma...@an...> - 2003-08-07 08:02:21
|
On Thu, 07 Aug 2003 00:56:09 -0700, Brian Goetz <br...@qu...> wrote: > >> Thanks for tracking this down Keats! >> >> Brian, is this a go-er? > > Sort of. The code Keats checked in appears to work around an existing > bug in ParserBlockBuilder, but doesn't fix it. It probably won't hurt, > but this bug is likely to come up again. ...can we go for a real fix then, for the sake of not causing problems for ourselves in the future - i.e. no "hidden" hacks that we forget which cause problems later and don't solve the whole problem anyway. Go on, Brian, please :) -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Brian G. <br...@qu...> - 2003-08-07 08:23:41
|
> ...can we go for a real fix then, for the sake of not causing problems for > ourselves in the future - i.e. no "hidden" hacks that we forget which cause > problems later and don't solve the whole problem anyway. > > Go on, Brian, please :) Nasty code. Sleeping dog lying... |
From: Marc P. <ma...@an...> - 2003-08-07 09:13:21
|
On Thu, 7 Aug 2003 01:23:27 -0700, Brian Goetz <br...@qu...> wrote: >> ...can we go for a real fix then, for the sake of not causing problems >> for ourselves in the future - i.e. no "hidden" hacks that we forget >> which cause problems later and don't solve the whole problem anyway. >> >> Go on, Brian, please :) > > Nasty code. Sleeping dog lying... Hmm, but this is what I'd call quite a serious bug in WM. It affects how people write templates. If you don't have time to address this, we'll have to do this without you :( [BUMP... the sound of the blind leading the blind!] Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Brian G. <br...@qu...> - 2003-08-07 18:31:04
|
> Hmm, but this is what I'd call quite a serious bug in WM. It affects how > people write templates. I don't see how. Keats' workaround deals with this case acceptably. Because of the underlying problem, there may be others, there probably are, but you have to find them first before you get to declare "serious bug." I'm inclined to let the underlying problem lie until other incidences crop up. The cost/benefit of fixing and testing the underlying problem seems unattractive. |
From: Marc P. <ma...@an...> - 2003-08-07 19:18:05
|
On Thu, 7 Aug 2003 11:30:04 -0700, Brian Goetz <br...@qu...> wrote: >> Hmm, but this is what I'd call quite a serious bug in WM. It affects how >> people write templates. > > I don't see how. Keats' workaround deals with this case acceptably. > Because of the underlying problem, there may be others, there probably > are, but you have to find them first before you get to declare > "serious bug." I'm inclined to let the underlying problem lie until > other incidences crop up. The cost/benefit of fixing and testing the > underlying problem seems unattractive. OK that's your take on it :-) Personally, cost/benefit analysis or not, I am not happy shipping software with known bugs that require workarounds - it's how code becomes mangled and twisted and you end up with a right old mess. If we're not going to get anybody who can fix this working on it though, a kludge it will have to be :( Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Marc P. <ma...@an...> - 2003-08-07 19:48:13
|
On Thu, 7 Aug 2003 11:30:04 -0700, Brian Goetz <br...@qu...> wrote: >> Hmm, but this is what I'd call quite a serious bug in WM. It affects how >> people write templates. > > I don't see how. Keats' workaround deals with this case acceptably. For the record, I meant if no workaround is applied, people have to write their templates differently to how they might like. ...because I don't like the hack idea, but if it's the best we can expect. Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |
From: Keats <ke...@ea...> - 2003-08-07 13:52:40
|
So I guess that means I should commit my patch for the time being? Keats ----- Original Message ----- From: "Brian Goetz" <br...@qu...> To: "Marc Palmer" <ma...@an...> Cc: "Keats" <ke...@ea...>; <web...@li...> Sent: Thursday, August 07, 2003 4:23 AM Subject: Re: [Webmacro-devel] Parser error: StringIndexOutOfRange > > ...can we go for a real fix then, for the sake of not causing problems for > > ourselves in the future - i.e. no "hidden" hacks that we forget which cause > > problems later and don't solve the whole problem anyway. > > > > Go on, Brian, please :) > > Nasty code. Sleeping dog lying... > |