You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Chris Holman <ch...@owl.co.uk> on 2002/02/28 11:43:40 UTC
Turbine 3:DefaultResolver question
If the method
String template = aDefaultResolver.getTemplate("moduleType", "");
is called, it currently throws an exception because a templatePath == "" is
deemed invalid.
Wouldnt it be better to return "default.vm"? See code below. Or is there
some underlying requirement for this functionality?
Chris
public class DefaultResolver
implements Resolver, TurbineConstants
{
...
public String getTemplate(String moduleType, String targetTemplate)
throws Exception
{
return findTemplate(moduleType, targetTemplate);
}
protected String findTemplate(String moduleType, String targetTemplate)
throws Exception
{
StringBuffer sb = new StringBuffer();
/******************************************
* EXCEPTION THROWN HERE BY: parseTemplatePath("", sb)
* Wouldnt it be better to catch this exception and
* allow getPossibleTemplates("") to return "default.vm"?
* Would require small mod to parseTemplatePath, as
* this exception indicates a malformed template path.
******************************************
int i = PipelineUtil.parseTemplatePath(targetTemplate, sb);
Iterator j = getPossibleTemplates(sb.toString());
while (j.hasNext())
{
String template = moduleType + "/" + (String) j.next();
if (Module.templateExists(template))
{
return template;
}
}
// We should have a default template type for
// each corresponding module and a default extension.
return moduleType + defaultTemplate;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>