Author: ssmiweve
Date: 2008-02-25 11:10:59 +0100 (Mon, 25 Feb 2008)
New Revision: 6164
Modified:
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
Log:
SEARCH-4310 - AbstractEnrichmentDirective, add support for unique templates per
placement
Modified:
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
===================================================================
---
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
2008-02-25 09:41:41 UTC (rev 6163)
+++
branches/2.16/generic.sesam/velocity-directives/src/main/java/no/sesat/search/view/velocity/AbstractEnrichmentDirective.java
2008-02-25 10:10:59 UTC (rev 6164)
@@ -29,13 +29,12 @@
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
-import java.util.WeakHashMap;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
import no.sesat.search.datamodel.DataModel;
import no.sesat.search.datamodel.search.SearchDataObject;
import no.sesat.search.result.ResultList;
import no.sesat.search.site.Site;
import no.sesat.search.view.config.SearchTab;
+import org.apache.velocity.Template;
import static no.sesat.search.view.config.SearchTab.EnrichmentHint.*;
import org.apache.velocity.app.VelocityEngine;
@@ -43,13 +42,17 @@
* Handles presenting the enrichments
*
* The first argument allow inclusion/exclusion of each enrichment according
to the subclasses implementation of
- * placementCorrect(tab, placement, i, e)
+ * placementCorrect(tab, placement, i, e) <br/><br/>
*
* The second argument specifies the a string to use in beginning wrapping
around each enrichment.
* a third argument is expected for end wrapping.
- * If no argument is specified no div is written around each enrichment.
+ * If no argument is specified no div is written around each enrichment.)
<br/><br/>
+ *
+ * The enrichments that are rendered are those named as the results field for
EnrichmentHint.NAME_KEY within the
+ * "templates/enrichments/${placement}/" directory. If this is not found then
the same named template
+ * within the "templates/enrichments/" directory is used.
*
- * @author mick
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mick Semb Wever</a>
* @version $Id$
*/
public abstract class AbstractEnrichmentDirective extends AbstractDirective {
@@ -144,7 +147,7 @@
// enrichments
- if (placementCorrect(getDataModel(cxt),placement, i, e)){
+ if (placementCorrect(getDataModel(cxt), placement, i, e)){
if(3 == node.jjtGetNumChildren()){
writer.append(getArgument(cxt, node, 1));
@@ -152,9 +155,19 @@
cxt.put("commandName", e.getField(NAME_KEY));
- VelocityEngineFactory
- .getTemplate(engine, site, "/enrichments/" +
e.getField(NAME_KEY))
- .merge(cxt, writer);
+ Template template = null;
+ try{
+ template = VelocityEngineFactory
+ .getTemplate(engine, site, "/enrichments/" +
placement + '/' + e.getField(NAME_KEY));
+
+ }catch(ResourceNotFoundException rnfe){
+ LOG.debug(rnfe.getMessage(), rnfe); // not important
+
+ template = VelocityEngineFactory
+ .getTemplate(engine, site, "/enrichments/" +
e.getField(NAME_KEY));
+ }
+
+ template.merge(cxt, writer);
if(3 == node.jjtGetNumChildren()){
writer.append(getArgument(cxt, node, 2));
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits