From: Keats <ke...@ea...> - 2003-06-27 21:19:53
|
I don't think the "to" option is worthwhile. You can accomplish the same thing with a simple #setblock: #setblock $var { #eval $templet using $map } So that leaves just: #eval $templet and #eval $templet using $map the first syntax is actually the same as just $templet so we might leave that out as well. Simple is good. Keats ----- Original Message ----- From: Lane Sharman To: Keats Cc: Sebastian Kanthak ; web...@li... Sent: Thursday, June 26, 2003 12:34 AM Subject: Re: [Webmacro-devel] #templet directive Directives are just that. They provide direction and control over the flow. A Directive is an intrinsic keyword for the WebMacro parser and evaluation engine. A property is an operator returning void, null, or an object. In the latter case, the object's string representation is added to the stream unless we are talking about assignment: #set $foo = $bar. A property is expanded. A directive is interpreted. As to the output directive, I agree that it complicates things. I think we should stick with directives which enhance the language. Property tools are the right place to do transformations and evaluations. I think we could use some that are more utilitarian for those who are creating non-web text and interacting with data flows as occurs in application integration. Can we finalize #templet now? #eval $template using { "foo":"a", "bar":"b" } #eval $template to $variable using { "foo":"a", "bar":"b" } #eval $template #eval $template to $variable Would be the #eval variations as I see them. The first two create an explicit context and the last two use the current context. The using ... option provides a nice way of creating a private context for the templet. The using ... option implies that the templet cannot update the context of the invoker. -Lane Keats wrote: I think your inference is falacious. Many directives write to the output stream, some use block arguments and some don't. The #include directive writes to the stream without a block arg. (And of course macros do this, but that's another issue.) I do think that a clear distinction between "expansion" -- putting something into the output stream, and "evaluation" -- performing some computation, would be helpful, but I can't think of a good way to do this without radically changing the WM syntax. It seems like the pattern that we've developed is that you use tools or functions for basic value transformations -- HTMLEscape, URLEncode, Math.mod, etc -- and directives for everything else. Better documentation would probably help here. Perhaps a taxonomy of directives, like: Control flow directives: #if/#elseif/#else #foreach #count Context altering directives (variable creation): #set #setblock #const/#attribute/#param #macro #alternate #bean #templet Text expansion directives: #include #eval #text Other: #comment #type #profile Keats ----- Original Message ----- From: "Sebastian Kanthak" <seb...@mu...> To: "Keats" <ke...@ea...> Cc: <web...@li...> Sent: Wednesday, June 25, 2003 3:25 PM Subject: Re: [Webmacro-devel] #templet directive Hi, On Monday 23 June 2003 16:37, Keats wrote: You could still do this sort of thing with the $Template tool. People didn't seem to like the template tool syntax, so I came up with the directive approach which seems a bit more user friendly. My approach to the above would be to use a directive for the writer, say #output ok, let's forget about the output thing. I only used this as an example. Like Brian, I personally do not think think it is necessary, but if Lane has a need for it, it's ok. My problem with the #eval-directive is of a more general nature: In WebMacro we basically have to possibilities to control the result of a template evaluation: 1) We can insert something into the output stream. This is usually done by a property reference $foo.bar 2) We can interact with the template engine and tell it to iterate certain blocks, chose one depending on a condition, set some properties and so on. Intuitively I think, that writing something into the output-stream (point 1) should be done via property references of the form $... and point 2 should be done via directives. Or to put it the other way round: I believe, that directives should not output anything by themselves. Of course the "#foreach" directive outputs a lot, but that comes from the block inside the directive, not from the directive itself. The same holds for "#if" and "#set" does not output anything at all. This is similar to the distinction between statements and expressions in most programming languages. I just realized, that this is how I thought about directives and property-refernces until now. In this picture a #templet directive would fit quite nice, because it just declares a template. However, for evaluating, I would find a $... syntax nicer. However, I must admit, that there exists directives (like those declared from macros), that do not fit in my own schema, so it is probably broken. But perhaps we can have some discussion about it: Do we have a consistent guideline, when to use $... syntax (via tools or macros) and when to use directives? I do not know of one and this is, where my confusion comes from. Sebastian -- Sebastian Kanthak PGP/GnuPG: http://www.muehlheim.de/~skanthak/pgp.html ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Webmacro-devel mailing list Web...@li... https://lists.sourceforge.net/lists/listinfo/webmacro-devel ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Webmacro-devel mailing list Web...@li... https://lists.sourceforge.net/lists/listinfo/webmacro-devel |
From: Marc P. <ma...@an...> - 2003-06-28 12:12:16
|
On Fri, 27 Jun 2003 16:33:48 -0400, Keats <ke...@ea...> wrote: > So that leaves just: > > #eval $templet > > and > > #eval $templet using $map > > the first syntax is actually the same as just > > $templet > > so we might leave that out as well. Simple is good. That looks much better to me. #template plus direct eval of template (using current context) or #eval $template using $map to use another context. I assume #eval will work with any Macro object, thus making it possible to use it with Macros created by other directives in the future. -- Marc Palmer Contract Java Consultant/Developer http://www.anyware.co.uk/marc/ http://www.wangjammers.org |
From: Keats <ke...@ea...> - 2003-07-21 15:26:26
|
I'm about ready to commit the #templet and #eval directives. I added a couple of things to #eval. In the new context of the #eval I add the following variables: $OuterVars, $EvalDepth, and $Self. $OuterVars is a reference to the the _variables Map of the top level calling context. $EvalDepth and $Self are used for recursive templets. Currently the max recursion depth is hard-coded at 100, but of course this could easily be configurable. I'll try to cook up some unit tests and commit this in the next day or so. Please give feedback. Here's a simple example of a recursive templet: #templet $treeRenderer { <b>$node.Title</b> #if ($List.size($node.Children) > 0){ <ul> #foreach $Child in $node.Children { <li> #eval $Self using {"node": $Child } </li> } </ul> } } #eval $treeRenderer using {"node": $treeRoot } (Note that in this example $Self is the same as $OuterVars.treeRenderer.) A simple tree is construction for this example is shown below: #set $grandchild1 = { "Title" : "First Grandchild", "Children" : [] } #set $grandchild2 = { "Title" : "Second Grandchild", "Children" : [] } #set $child1 = { "Title" : "Child 1", "Children" : [] } #set $child2 = { "Title" : "Child 2", "Children" : [$grandchild1, $grandchild2] } #set $treeRoot = { "Title" : "Root Node", "Children" : [ $child1, $child2] } Keats |
From: Lane S. <la...@op...> - 2003-07-21 18:29:08
|
Hi Keats, This looks really promising. I am very eager to try this out; and, I would be willing to help with unit test execution, development. -Lane Keats wrote: >I'm about ready to commit the #templet and #eval directives. I added a >couple of things to #eval. In the new context of the #eval I add the >following variables: $OuterVars, $EvalDepth, and $Self. > >$OuterVars is a reference to the the _variables Map of the top level calling >context. > >$EvalDepth and $Self are used for recursive templets. Currently the max >recursion depth is hard-coded at 100, but of course this could easily be >configurable. > >I'll try to cook up some unit tests and commit this in the next day or so. >Please give feedback. > >Here's a simple example of a recursive templet: > >#templet $treeRenderer { > <b>$node.Title</b> > #if ($List.size($node.Children) > 0){ > <ul> > #foreach $Child in $node.Children { > <li> > #eval $Self using {"node": $Child } > </li> > } > </ul> > } >} >#eval $treeRenderer using {"node": $treeRoot } > >(Note that in this example $Self is the same as $OuterVars.treeRenderer.) > >A simple tree is construction for this example is shown below: > >#set $grandchild1 = { > "Title" : "First Grandchild", > "Children" : [] >} > >#set $grandchild2 = { > "Title" : "Second Grandchild", > "Children" : [] >} > >#set $child1 = { > "Title" : "Child 1", > "Children" : [] >} > >#set $child2 = { > "Title" : "Child 2", > "Children" : [$grandchild1, $grandchild2] >} > >#set $treeRoot = { > "Title" : "Root Node", > "Children" : [ $child1, $child2] >} > >Keats > > > >------------------------------------------------------- >This SF.net email is sponsored by: VM Ware >With VMware you can run multiple operating systems on a single machine. >WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the >same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 >_______________________________________________ >Webmacro-devel mailing list >Web...@li... >https://lists.sourceforge.net/lists/listinfo/webmacro-devel > > > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga Java Software Portal: http://opendoors.com |
From: Marc P. <ma...@an...> - 2003-07-23 09:57:43
|
On Mon, 21 Jul 2003 11:25:41 -0400, Keats <ke...@ea...> wrote: > I'm about ready to commit the #templet and #eval directives. I added a > couple of things to #eval. In the new context of the #eval I add the > following variables: $OuterVars, $EvalDepth, and $Self. This looks really cool Keats. May I suggest an alternative naming for $OuterVars though? How about: $Outer or $Template This might seem to make more sense - i.e. $Outer.myVar or $Template.myVar. The latter may be more confusing, but it's "correct" in the sense that it takes vars from the template being rendered rather than the templet. Can #eval take a Macro as the templet name? i.e. #eval "render$FieldType" using $myMap ? I look forward to trying this out! -- 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-07-23 14:14:05
|
> May I suggest an alternative naming for $OuterVars though? How about: > > $Outer or $Template $Outer would probably be OK. > This might seem to make more sense - i.e. $Outer.myVar or $Template.myVar. > The latter may be more confusing, but it's "correct" in the sense that it > takes vars from the template being rendered rather than the templet. > > Can #eval take a Macro as the templet name? i.e. #eval "render$FieldType" > using $myMap ? #eval can work with any Macro, but it must be in a variable. #templet just stores a Block in a variable, just like "#setblock as macro". You should be able to put any Macro implementation into the context and invoke it with #eval. E.g., // Java Template t = new StringTemplate(broker, "$A $B $C"); context.put("abc", t); ## WMScript #eval $abc using { "A": "Three", "B": "blind", "C": "mice" } (Sorry, I was reading nursery rhymes to my daughter this morning.) > I look forward to trying this out! Please do. I'll try to commit today. Keats |
From: Marc P. <ma...@an...> - 2003-07-23 16:11:13
|
On Wed, 23 Jul 2003 10:11:37 -0400, Keats <ke...@ea...> wrote: >> May I suggest an alternative naming for $OuterVars though? How about: >> >> $Outer or $Template > > $Outer would probably be OK. It just seems a little cleaner. >> Can #eval take a Macro as the templet name? i.e. #eval >> "render$FieldType" >> using $myMap ? > > #eval can work with any Macro, but it must be in a variable. #templet > just > stores a Block in a variable, just like "#setblock as macro". You should > be > able to put any Macro implementation into the context and invoke it with > #eval. E.g., > > // Java > Template t = new StringTemplate(broker, "$A $B $C"); > context.put("abc", t); > > ## WMScript > #eval $abc using { "A": "Three", "B": "blind", "C": "mice" } > > (Sorry, I was reading nursery rhymes to my daughter this morning.) Hehe. I'm afraid I think you've misunderstood me though. What I mean is can I alter the name of the macro to #eval dynamically - i.e.: #set $FieldType = "name" #eval "render$FieldType" using $myMap #set $FieldType = "date" #eval "render$FieldType" using $myMap #set $FieldType = "email" #eval "render$FieldType" using $myMap ...from what you say I don't think this is possible, but could we make it possible somehow? It would really make rendering things from a flexible schema (based on type) so much easier. Otherwise we have to use #include with lots of little script files. >> I look forward to trying this out! > > Please do. I'll try to commit today. Great! FWIW I've been using the head revision today (Brian's profiling removals etc) and its working fine here as far as I can tell. That webmacro.jar just keeps on shrinking! 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-07-23 16:19:55
|
On Wed, 23 Jul 2003 17:11:03 +0100, Marc Palmer <ma...@an...> wrote: > What I mean is can I alter the name of the macro to #eval dynamically - > i.e.: > > #set $FieldType = "name" > #eval "render$FieldType" using $myMap > #set $FieldType = "date" > #eval "render$FieldType" using $myMap > #set $FieldType = "email" > #eval "render$FieldType" using $myMap Hmm, of course that is not possible at the moment but I wonder how we could make it so we can do something like that. Would we be looking at an alternative syntax for variable resolution (PropertyOperatorCache hell noooooooo!) such as: The value of your dynamic var is: $"render$SomeVar" Truly nasty, I grant you. I'm just trying to think of a way to achieve this. -- 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-07-23 16:36:34
|
On Wed, 23 Jul 2003 17:18:12 +0100, Marc Palmer <ma...@an...> wrote: >> What I mean is can I alter the name of the macro to #eval dynamically - >> i.e.: >> >> #set $FieldType = "name" >> #eval "render$FieldType" using $myMap >> #set $FieldType = "date" >> #eval "render$FieldType" using $myMap >> #set $FieldType = "email" >> #eval "render$FieldType" using $myMap > > Hmm, of course that is not possible at the moment but I wonder how we > could make it so we can do something like that. Would we be looking at an > alternative syntax for variable resolution (PropertyOperatorCache hell > noooooooo!) such as: > > The value of your dynamic var is: $"render$SomeVar" > > Truly nasty, I grant you. I'm just trying to think of a way to achieve > this. Hmm one way to achieve this that isn't as anywhere as clean as I'd like is: #template $templetA ... #end #template $templetB ... #end #template $templetC ... #end #set $renderers = {} #set $renderers.email = $templetA #set $renderers.name = $templetB #set $renderers.date = $templetC #set $FieldType = "name" #eval $renderers.get($FieldType) using $myMap #set $FieldType = "date" #eval $renderers.get($FieldType) using $myMap #set $FieldType = "email" #eval $renderers.get($FieldType) using $myMap It's doable, and arguably nicer than a series of small template include files, but it's error-prone in terms of forgetting to add a templet to the $renderers map. It's progress though. Any other bright ideas? How about a context-aware function that gets a variable from the current context by name? i.e: #set $var = $GetVariable("renderer$FieldType") which would then work as: #set $FieldType = "name" #eval $GetVariable("renderer$FieldType") using $myMap #set $FieldType = "date" #eval $GetVariable("renderer$FieldType") using $myMap #set $FieldType = "email" #eval $GetVariable("renderer$FieldType") using $myMap This would seem to be a much nicer solution, though I am sure somebody will not like it. :-) 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: Lane S. <la...@op...> - 2003-07-23 17:16:32
|
Marc Palmer wrote: > On Wed, 23 Jul 2003 17:11:03 +0100, Marc Palmer <ma...@an...> > wrote: > > > Truly nasty, I grant you. I'm just trying to think of a way to achieve > this. I think it is too much English briar bush or one of those monster sand traps from hell you brits like to play in. :) -L > > > > > |
From: Keats <ke...@ea...> - 2003-07-23 17:06:53
|
> What I mean is can I alter the name of the macro to #eval dynamically - > i.e.: > > #set $FieldType = "name" > #eval "render$FieldType" using $myMap > #set $FieldType = "date" > #eval "render$FieldType" using $myMap > #set $FieldType = "email" > #eval "render$FieldType" using $myMap > I'm not sure exactly what you're trying to do, but let me guess. You have Macros defined in variables $renderName, $renderDate, and $renderEmail. You'd like to invoke the appropriate macro based on $FieldType. How about using a map: #set $renders = { "Name": $renderName, "Date": $renderDate, "Email": $renderEmail } #set $renderer = $renderers.Name #eval $renderer using $myMap #set $renderer = $renderers.Date #eval $renderer using $myMap #set $renderer = $renderers.Email #eval $renderer using $myMap You could also do this using some kind of Macro indirection, but that's kind of tricky and unintuitive. Something like: #templet $rendererMacro { \$render$FieldType } #set $FieldType="Name" #eval $rendererMacro using $myMap #set $FieldType="Date" #eval $rendererMacro using $myMap #set $FieldType="Email" #eval $rendererMacro using $myMap I think something like this could work. Maybe I'll try it later. We could add a simple method to the VariableTool (remember that one? Not much used anymore), like: $Variable.get("render$FieldType") or, of course, a context-aware function: $variable("render$FieldType") Keats |
From: Lane S. <la...@op...> - 2003-07-23 17:14:54
|
Marc Palmer wrote: > On Wed, 23 Jul 2003 10:11:37 -0400, Keats <ke...@ea...> wrote: > #set $FieldType = "name" > #eval "render$FieldType" using $myMap > #set $FieldType = "date" > #eval "render$FieldType" using $myMap > #set $FieldType = "email" > #eval "render$FieldType" using $myMap how about using a macro today, Marc. The above indirection buys you a can of worms. Do this today: #rendername $myMap #renderdate $myMap #renderemail $myMap -Lane > > > ...from what you say I don't think this is possible, but could we make > it possible somehow? It would really make rendering things from a > flexible schema (based on type) so much easier. > > Otherwise we have to use #include with lots of little script files. > >>> I look forward to trying this out! >> >> >> Please do. I'll try to commit today. > > > Great! > > FWIW I've been using the head revision today (Brian's profiling > removals etc) and its working fine here as far as I can tell. That > webmacro.jar just keeps on shrinking! > > Marc |
From: Marc P. <ma...@an...> - 2003-07-23 17:34:03
|
On Wed, 23 Jul 2003 10:06:00 -0700, Lane Sharman <la...@op...> wrote: >> On Wed, 23 Jul 2003 10:11:37 -0400, Keats <ke...@ea...> wrote: >> #set $FieldType = "name" >> #eval "render$FieldType" using $myMap >> #set $FieldType = "date" >> #eval "render$FieldType" using $myMap >> #set $FieldType = "email" >> #eval "render$FieldType" using $myMap > > how about using a macro today, Marc. The above indirection buys you a can > of worms. Do this today: > > #rendername $myMap > #renderdate $myMap > #renderemail $myMap No, that is exactly what I want to avoid! I am doing that at the moment and it's really bad news I'm afraid. It's very boring and results in huge #if...#elseif statements if you have lots of types. What I'm trying to do is exactly like: #include as template "snippets/$(fieldType).wmt" ...but for calling macros/templets. I will not know at template-writing time what types will be available, so I cannot do this unless I force my end-user (web guy) to maintain this file, which is not desirable. i.e. given a list of field objects with a type name associate with them, I want to be doing this: #include as macro "includes/fieldRenderers.wmt" #set $vars = { "values" : $valuesMap } #foreach $field in $fieldList #eval $GetVariable("render$field.TypeName") using $vars #end This way the template is clean and free of schema dependencies. Anybody introducing new types simply has to edit fieldRenderers.wmt to add a templet for the type they need. It's simple and completely hassle-free. As Keats has backed up my thoughts on this (using a Map) and pointed out the indirection approach, I think we're getting somewhere. I think the context-aware function is the best bet, used to obtain the variable containing the templet. 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: Lane S. <la...@op...> - 2003-07-23 17:06:24
|
Keats wrote: >Please do. I'll try to commit today. > >Keats > I added this feature to the NextRelease wiki page. -Lane > > > >------------------------------------------------------- >This SF.net email is sponsored by: VM Ware >With VMware you can run multiple operating systems on a single machine. >WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the >same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 >_______________________________________________ >Webmacro-devel mailing list >Web...@li... >https://lists.sourceforge.net/lists/listinfo/webmacro-devel > > > |
From: Lane S. <la...@op...> - 2003-03-28 22:37:01
|
> > > Anyway, I'll try to write some unit tests > music to my ears :) |
From: Keats K. <kea...@na...> - 2003-03-30 00:16:26
|
Strangely I can't reproduce this error on my home machine. I created some tests and added them to the test/unit org.webmacro.template.TestGetSet class and everything seems to be working. Could this be a platform specific problem? I'm running WinXP Home with Sun's JDK 1.4.1_01 at home. At the office I have Win2K and a similar JDK version. If other folks could try this test on different platforms I'd appreciated it. Keats kea...@na... wrote: > Marc, > > I think I have finally tracked this one down. > > Line 781 in PropertyOperatorCache.java, in the > PropertyOperatorCache.PropertyOperator.setProperty() method: > > parent = getProperty(context, instance, names, pos, pos); > > should be: > > parent = getProperty(context, instance, names, pos, pos + > 1); > > Don't ask me to explain this (I can't). I'm guessing that this bug > has been in the code forever. I suppose not many people have tried to > use the binary mutator syntax, i.e., > > #set $obj.Prop.Key = "value" > > for > > $obj.setProp("Key", "value") > > Anyway, I'll try to write some unit tests for this and make sure it > doesn't break anything before committing the change. > > Keats > > > > > -----Original Message----- > > From: Marc Palmer [mailto:ma...@an...] > > Sent: Wednesday, March 19, 2003 10:19 PM > > To: web...@li... > > Subject: [Webmacro-devel] Binary accessor "set" problem > > > > > > > > Hi all, > > > > I'm working against WM 1.1 final source, developing this WM > > "run and go" > > webapp currently codenamed "WebMacro Ignition". > > > > I've come across a funny. I can't -set-a property that has a binary > > accessor. A glance over the WM source for this > > (PropertyOperatorCache) has > > not enlightened me and the laptop I'm using is just toooo slow for > > interactive debug against Tomcat at the mo. > > > > Anyway, I'm getting this error in my template: > > > > Ignition encountered an error while executing a template: > > FileTemplate:C:\Program Files\Apache Group\Tomcat > > 4.1\webapps\ignition\WEB- > > INF\classes\index.wm: > > org.webmacro.PropertyException$NoSuchPropertyException: No > > public property > > Parameters on variable $action of class > > org.webmacro.ignition.api.action.ActionParams at C:\Program > > Files\Apache > > Group\Tomcat 4.1\webapps\ignition\WEB-INF\classes\index.wm:17.2 > > > > The part of the template causing offence is: > > > > #set $action.Parameters.Template = "itworked.wm" > > > > ...and $action is of type ActionParams which has the > > following methods: > > > > public void setParameters(String key, Object value) > > > > public String getParameters(String key) > > > > ... I know binary accessor "get" works as have used it > > elsewhere but this > > is the first time I've tried to "set" using it. > > > > Also, while binary accessor is certainly a convenience I'm > > starting to > > wonder whether it is a bit of an abomination. i.e. you cannot > > rewrite my > > previous bit of WM script as this: > > > > #set $params = $action.Parameters > > #set $params.Template = "itworked.wm" > > > > Well... you could if there was a "proxy" created to represent > > the virtual > > field "Parameters" internally in WM that handled this but it would be > > pretty nasty. Granted many web developers would not think of > > doing this, > > but it disturbs me that we can get ourselves into an > > inconsistent situation > > by using binary accessors. I think I may stop using them > > having realised > > this. > > > > $0.02 > > > <snip> > |
From: Lane S. <la...@op...> - 2003-03-30 00:38:34
|
did you commit the test to cvs so I can check it out? -Lane Keats Kirsch wrote: > Strangely I can't reproduce this error on my home machine. I created > some tests and added them to the test/unit > org.webmacro.template.TestGetSet class and everything seems to be > working. > Could this be a platform specific problem? I'm running WinXP Home > with Sun's JDK 1.4.1_01 at home. At the office I have Win2K and a > similar JDK version. If other folks could try this test on different > platforms I'd appreciated it. > > Keats > > kea...@na... wrote: > >> Marc, >> >> I think I have finally tracked this one down. >> >> Line 781 in PropertyOperatorCache.java, in the >> PropertyOperatorCache.PropertyOperator.setProperty() method: >> >> parent = getProperty(context, instance, names, pos, pos); >> >> should be: >> >> parent = getProperty(context, instance, names, pos, pos >> + 1); >> >> Don't ask me to explain this (I can't). I'm guessing that this bug >> has been in the code forever. I suppose not many people have tried >> to use the binary mutator syntax, i.e., >> >> #set $obj.Prop.Key = "value" >> >> for >> >> $obj.setProp("Key", "value") >> >> Anyway, I'll try to write some unit tests for this and make sure it >> doesn't break anything before committing the change. >> >> Keats >> >> >> >> > -----Original Message----- >> > From: Marc Palmer [mailto:ma...@an...] >> > Sent: Wednesday, March 19, 2003 10:19 PM >> > To: web...@li... >> > Subject: [Webmacro-devel] Binary accessor "set" problem >> > >> > >> > >> > Hi all, >> > >> > I'm working against WM 1.1 final source, developing this WM >> > "run and go" >> > webapp currently codenamed "WebMacro Ignition". >> > >> > I've come across a funny. I can't -set-a property that has a binary >> > accessor. A glance over the WM source for this > >> (PropertyOperatorCache) has >> > not enlightened me and the laptop I'm using is just toooo slow for >> > interactive debug against Tomcat at the mo. >> > >> > Anyway, I'm getting this error in my template: >> > >> > Ignition encountered an error while executing a template: >> > FileTemplate:C:\Program Files\Apache Group\Tomcat >> > 4.1\webapps\ignition\WEB- >> > INF\classes\index.wm: >> > org.webmacro.PropertyException$NoSuchPropertyException: No >> > public property >> > Parameters on variable $action of class >> > org.webmacro.ignition.api.action.ActionParams at C:\Program >> > Files\Apache >> > Group\Tomcat 4.1\webapps\ignition\WEB-INF\classes\index.wm:17.2 >> > >> > The part of the template causing offence is: >> > >> > #set $action.Parameters.Template = "itworked.wm" >> > >> > ...and $action is of type ActionParams which has the >> > following methods: >> > >> > public void setParameters(String key, Object value) >> > >> > public String getParameters(String key) >> > >> > ... I know binary accessor "get" works as have used it >> > elsewhere but this >> > is the first time I've tried to "set" using it. >> > >> > Also, while binary accessor is certainly a convenience I'm >> > starting to >> > wonder whether it is a bit of an abomination. i.e. you cannot >> > rewrite my >> > previous bit of WM script as this: >> > >> > #set $params = $action.Parameters >> > #set $params.Template = "itworked.wm" >> > >> > Well... you could if there was a "proxy" created to represent >> > the virtual >> > field "Parameters" internally in WM that handled this but it would be >> > pretty nasty. Granted many web developers would not think of >> > doing this, >> > but it disturbs me that we can get ourselves into an >> > inconsistent situation >> > by using binary accessors. I think I may stop using them >> > having realised >> > this. >> > >> > $0.02 >> > >> <snip> >> > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: > The Definitive IT and Networking Event. Be There! > NetWorld+Interop Las Vegas 2003 -- Register today! > http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en > _______________________________________________ > Webmacro-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-devel > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga Java Software Portal: http://opendoors.com |
From: Keats K. <kea...@na...> - 2003-03-30 16:24:22
|
Lane Sharman wrote: > did you commit the test to cvs so I can check it out? Yes. See: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/webmacro/webmacro/test/unit/org/webmacro/template/TestGetSet.java I'd appreciated if you tried it out. Keats |