That is odd. Velocity is not a typeless environment, but you are setting a context variable and those are typeless (or ought to be). If this is truly the root problem, then it is a bug. If it's not too much trouble, would you continue working to provide me an example i can try out myself? There's something funky going on here.
On Thu, Jun 26, 2008 at 10:57 AM, Steve O'Hara <[EMAIL PROTECTED]> wrote: > Hi Nathan, > > By cutting down the example to it's bare bones, I've discovered the > problem. > > The following statement causes some sort of error within Velocity (not > announced in the logger) that only occurs when the template is cached. > > #set($FieldNames="one,two,three") > ....... > #set($FieldNames=$utils.splitToList($FieldNames,",")) > > I think that maybe we're playing fast and loose with velocity and it's > type management, because what we're doing here is assigning a List to > the same variable that formerly contained a String. > > When this is run without caching it works fine but once caching is on, > it fails. > By changing the statement to this, it works fine. > > #set($FieldNamesList=$utils.splitToList($FieldNames,",")) > > Perhaps not really a bug, more of a nudge for us to remember that > velocity is not type-less? > > Thanks, > Steve > > > -----Original Message----- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > .org] On Behalf Of Nathan Bubna > Sent: 24 June 2008 03:32 > To: Velocity Users List > Subject: Re: Strange Caching Problem with Macros > > can you replicate this with a simpler example at all? it's a bit hard > to spot the tree in the forest. :) it's not obvious to me what the > problem is, and i can't run your example, so it's rather hard to track > down. could you also let us know what version of Velocity this is and > perhaps what your velocity.properties are when you experience this? > > On Sun, Jun 22, 2008 at 4:55 AM, Steve O'Hara > <[EMAIL PROTECTED]> wrote: >> >> I'm getting a problem when caching is turned on whereby a method call > is >> not being run consistently. >> >> I have a macro as per below; >> >> #macro(macroShowGrid $FieldNames $SortFieldName) >> >> #set($Rows=$Entity.getConstituentGrid($FieldNames,$SortFieldName)) >> #if ($PreviousBrand) >> > #set($OldRows=$PreviousBrand.getConstituentGrid($FieldNames,$SortFieldNa >> me)) #end >> #set($FieldNames=$utils.splitToList($FieldNames,",")) >> >> #foreach($Row in $Rows) >> <tr> >> #foreach($Field in $FieldNames) >> #if ($velocityCount==1) #macroWriteImage($Row > $Field >> "") #end >> <td >> style="background-color:white;vertical-align:top;"> >> #if ($velocityCount==1) >> #set($Number=$Row.get($Field)) >> #if($Number.matches("[0-9]+")) >> >> > #set($Url="$AppPath/$PageType/explorer?datasrc=$DataSource&new&view=bran >> d&key=$Number") >> #else >> >> > #set($Url="$AppPath/$PageType/explorer?datasrc=$DataSource&new&view=inde >> x&minutenumber=$Number") >> #end >> <a href="$Url" target="_blank" >> #macroMouseOver("View this record")>$Row.get($Field)</a> >> #else >> $Row.get($Field) >> #end >> </td> >> #end >> </tr> >> #end >> #end >> >> This macro is called from with another macro; >> >> #macro(macroShowProductIngredients $FieldName $FieldTitle >> $FieldComment $FieldList $FieldOrder) >> #if ($Entity.getValue($FieldName).length()>0 || >> $Entity.getValue($FieldComment).length()>0) >> <table border="1" bordercolor="#CDCB99" cellspacing="0" >> cellpadding="3" bgcolor="#E2E0C8" >> style="margin-top:8px;margin-left:4px"> >> <tr> >> <td colspan="5">$FieldTitle</td> >> </tr> >> <tr> >> #set($Fields=$utils.splitToList($FieldList,",")) >> <td nowrap width="100" colspan="2"align="center">Minute >> Number</td> >> <td nowrap width="100%">Description</td> >> <td nowrap align="center">Level (%)</td> >> <td nowrap width="150" align="left">Supplier</td> >> </tr> >> #macroShowGrid($FieldList $FieldOrder) >> #set($PreviousFieldValue="") >> #set($FieldValue="") >> #if ($PreviousBrand) >> #set($PreviousFieldValue=$PreviousBrand.getValue($FieldComment)) #end >> #set ($FieldValue=$Entity.getValue($FieldComment)) >> #if ($FieldValue.length()>0 || $PreviousFieldValue.length>0 >> || $PreviousBrand) >> <tr> >> <td bgcolor="#FFFFFF" valign="top" colspan="5"> >> #macroShowValue($FieldValue > $PreviousFieldValue) >> </td> >> </tr> >> #end >> </table> >> #end >> #end >> >> >> >> All works fine when caching is turned off but when I turn it on, the >> method call $Entity.getConstituentGrid($FieldNames,$SortFieldName) is >> not being run. The value of $Rows is always undefined. I say always, > I >> don't mean always, it seems to be a bit intermittent. >> These macros are inline and I'm using a custom file based resource >> loader. >> >> My understanding of caching was that it cached the structure of the >> template in an AST, not the contents? >> I've checked that the $Entity object is valid, which it is and that it >> has a different Class ID each call, which it does which would indicate >> the Context is definitely getting given a different Entity each call. >> The parameters are correct for the call too. >> >> Thanks, >> Steve >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
