playframeworkからselectタグをコピーして、fasttagと同様にタグの作成をテストします(オプションをファストタグとして実行しています)。しかし、唯一の問題は、それがfasttagを探してしなければならないとき、私はこのエラーを取得...私のplayframeworkファストタグが何らかの理由でピックアップされていない
The template tags/alvazan/option.html or tags/alvazan/option.tag does not exist.
マイFastTagsクラスは、アプリ/ tagsディレクトリにあり、次のコードです....
package tags;
import groovy.lang.Closure;
import java.io.PrintWriter;
import java.util.Map;
import play.templates.FastTags;
import play.templates.JavaExtensions;
import play.templates.TagContext;
import play.templates.GroovyTemplate.ExecutableTemplate;
@FastTags.Namespace("alvazan")
public class TagHelp extends FastTags {
public static void _option(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
Object value = args.get("arg");
TagContext ctx = TagContext.parent("alvazanselect");
Object selectedValue = ctx.data.get("selected");
boolean selected = selectedValue != null && value != null && (selectedValue.toString()).equals(value.toString());
out.print("<option value=\"" + (value == null ? "" : value) + "\" " + (selected ? "selected=\"selected\"" : "") + " " + FastTags.serialize(args, "selected", "value") + ">");
out.println(JavaExtensions.toString(body));
out.print("</option>");
}
}
私のHTMLが見つからないされ、これを持っている...
#{alvazan.option/}
ここのコードは、それは...(ここで、隠されたfasttagsを検索するコードがある)fasttagを見上げることはない意味
のpublic void invokeTag(Integer fromLine, String tag, Map<String, Object> attrs, Closure body) {
String templateName = tag.replace(".", "/");
String callerExtension = "tag";
if (template.name.indexOf(".") > 0) {
callerExtension = template.name.substring(template.name.lastIndexOf(".") + 1);
}
BaseTemplate tagTemplate = null;
try {
tagTemplate = (BaseTemplate)TemplateLoader.load("tags/" + templateName + "." + callerExtension);
} catch (TemplateNotFoundException e) {
try {
tagTemplate = (BaseTemplate)TemplateLoader.load("tags/" + templateName + ".tag");
} catch (TemplateNotFoundException ex) {
if (callerExtension.equals("tag")) {
throw new TemplateNotFoundException("tags/" + templateName + ".tag", template, fromLine);
}
throw new TemplateNotFoundException("tags/" + templateName + "." + callerExtension + " or tags/" + templateName + ".tag", template, fromLine);
}
}
TagContext.enterTag(tag);
Map<String, Object> args = new HashMap<String, Object>();
args.put("session", getBinding().getVariables().get("session"));
args.put("flash", getBinding().getVariables().get("flash"));
args.put("request", getBinding().getVariables().get("request"));
args.put("params", getBinding().getVariables().get("params"));
args.put("play", getBinding().getVariables().get("play"));
args.put("lang", getBinding().getVariables().get("lang"));
args.put("messages", getBinding().getVariables().get("messages"));
args.put("out", getBinding().getVariable("out"));
args.put("_attrs", attrs);
// all other vars are template-specific
args.put("_caller", getBinding().getVariables());
if (attrs != null) {
for (Map.Entry<String, Object> entry : attrs.entrySet()) {
args.put("_" + entry.getKey(), entry.getValue());
}
}
args.put("_body", body);
try {
tagTemplate.internalRender(args);
} catch (TagInternalException e) {
throw new TemplateExecutionException(template, fromLine, e.getMessage(), template.cleanStackTrace(e));
} catch (TemplateNotFoundException e) {
throw new TemplateNotFoundException(e.getPath(), template, fromLine);
}
TagContext.exitTag();
}
2質問
- は、なぜこれが動作しませんか?
- htmlファイルを検索するのではなく、fasttag "class"を検索するplayframeworkソースのコードはどこですか?
ありがとう、なぜそれが見つからなかったのか把握するために私はそれをデバッグする必要があります....ありがとう、それは私がうずまきを乗り越えるのを助けるはずです。 –