lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <p...@hoplahup.net>
Subject Re: Help with Velocity in SolrItas
Date Tue, 09 Oct 2012 06:33:14 GMT
Lance,

this is the kind of fun that happens with Velocity all day long...

In general, when it outputs the variable name, it's the that the variable is null; this can
happen when a method is missing for example.... 
There are actually effective uses of this brain-dead-debugger-oriented-practice!

I would suppose that the class of your $sentence is not something that has a get(String) method.
With a normal debugging, this should be shown in a console.
This is strengthened by the fact that your output of $sentence is not exactly the same as
a the output of  java.util.HashMap for example.

When in this situation, I generally make
   Raw data: $sentence of class $sentence.getClass()
(note: class is not a bean property, you need the method call)

Hope it helps.

Paul

PS: to stop this hell, I have a JSP pendant to the VelocityResponseWriter, is this something
of interest for someone so that I contribute it?



Le 9 oct. 2012 à 04:39, Lance Norskog a écrit :

> I am adding something to Solaritas, under /browse. One bit of Velocity
> code does not unpack the result structure the way I think it should.
> Please look at this- there is something I am missing about
> tree-walking.
> 
> Here is the XML from a search result:
> <lst name="outer">
>  <lst name="sentence">
>    <int name="index">0</int>
>    <str name="text">
>    A bunch of words
>    </str>
>  </lst>
> more sentences ....
> </lst>
> 
> Here is my Velocity code:
> #foreach($sentence in $outer)
>    Raw data: $sentence
>    <br/>
>    #set($index = $sentence.get('index'))
>    #set($text = $sentence.get('text'))
>    <div class="text">
>      Index: $index
>      <br/>
>      Text: $text
>      <br/>
>    </div>
> #end
> 
> Here is the output:
> 
>    Raw data: sentence={index=0,text= A bunch of words}
>    Index: $index
>    Text: $text


Mime
View raw message