com.jfinal.template.Engine Java Examples
The following examples show how to use
com.jfinal.template.Engine.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceApiGenerator.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void generate(List<TableMeta> tableMetas) { System.out.println("Generate base model ..."); System.out.println("Base Model Output Dir: " + baseModelOutputDir); Engine engine = Engine.create("forService"); engine.setSourceFactory(new ClassPathSourceFactory()); engine.addSharedMethod(new StrKit()); engine.addSharedObject("getterTypeMap", getterTypeMap); engine.addSharedObject("javaKeyword", javaKeyword); for (TableMeta tableMeta : tableMetas) { genBaseModelContent(tableMeta); } writeToFile(tableMetas); }
Example #2
Source File: ArticleNotifyKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendEmail(Article article, ArticleComment comment, User user) { String emailTemplate = JPressOptions.get("article_comment_email_notify_template"); String emailTitle = JPressOptions.get("article_comment_email_notify_title"); String webMasterEmail = JPressOptions.get("web_mater_email"); if (!StrUtil.areNotEmpty(emailTemplate, emailTitle, webMasterEmail)) { return; } Map<String, Object> paras = new HashMap(); paras.put("article", article); paras.put("comment", comment); paras.put("user", user); String title = Engine.use().getTemplateByString(emailTitle).renderToString(paras); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(webMasterEmail.split(",")); email.send(); }
Example #3
Source File: PageNotifyKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendEmail(SinglePage page, SinglePageComment comment, User user) { String emailTemplate = JPressOptions.get("page_comment_email_notify_template"); String emailTitle = JPressOptions.get("page_comment_email_notify_title"); String webMasterEmail = JPressOptions.get("web_mater_email"); if (!StrUtil.areNotEmpty(emailTemplate, emailTemplate, webMasterEmail)) { return; } Map<String, Object> paras = new HashMap(); paras.put("page", page); paras.put("comment", comment); paras.put("user", user); String title = Engine.use().getTemplateByString(emailTitle).renderToString(paras); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(webMasterEmail.split(",")); email.send(); }
Example #4
Source File: PrePayNotifytKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendWechat(PaymentRecord payment, User user) { String emailTemplate = JPressOptions.get("prepay_notify_wechat_template"); String webMasterOpenId = JPressOptions.get("web_mater_wxopenid"); if (!StrUtil.areNotEmpty(emailTemplate, emailTemplate)) { return; } Map<String, Object> paras = new HashMap(); paras.put("payment", payment); paras.put("user", user); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Set<String> openIds = StrUtil.splitToSet(webMasterOpenId, ","); for (String openId : openIds) { WechatMsgUtil.sendImageAsync(openId, content); } }
Example #5
Source File: PrePayNotifytKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendEmail(PaymentRecord payment, User user) { String emailTemplate = JPressOptions.get("prepay_notify_email_template"); String emailTitle = JPressOptions.get("prepay_notify_email_title"); String webMasterEmail = JPressOptions.get("web_mater_email"); if (!StrUtil.areNotEmpty(emailTemplate, emailTemplate, webMasterEmail)) { return; } Map<String, Object> paras = new HashMap(); paras.put("payment", payment); paras.put("user", user); String title = Engine.use().getTemplateByString(emailTitle).renderToString(paras); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(webMasterEmail.split(",")); email.send(); }
Example #6
Source File: PayNotifytKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendEmail(PaymentRecord payment, User user) { String emailTemplate = JPressOptions.get("pay_notify_email_template"); String emailTitle = JPressOptions.get("pay_notify_email_title"); String webMasterEmail = JPressOptions.get("web_mater_email"); if (!StrUtil.areNotEmpty(emailTemplate, emailTitle, webMasterEmail)) { return; } Map<String, Object> paras = new HashMap(); paras.put("payment", payment); paras.put("user", user); String title = Engine.use().getTemplateByString(emailTitle).renderToString(paras); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(webMasterEmail.split(",")); email.send(); }
Example #7
Source File: EnjoyTemplateHandler.java From myexcel with Apache License 2.0 | 6 votes |
@Override protected Engine getTemplateEngineSupplier(String dirPath) { synchronized (EnjoyTemplateHandler.class) { Engine engine = CFG_MAP.get(dirPath); if (engine != null) { return engine; } engine = Engine.create("myexcel_" + dirPath); Engine.setFastMode(true); if (Objects.equals(dirPath, CLASSPATH)) { engine.setBaseTemplatePath(null); engine.setToClassPathSourceFactory(); } else { engine.setBaseTemplatePath(dirPath); } CFG_MAP.put(dirPath, engine); return engine; } }
Example #8
Source File: ProductNotifyKit.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
private static void doSendEmail(Product product, ProductComment comment, User user) { String emailTemplate = JPressOptions.get("product_comment_email_notify_template"); String emailTitle = JPressOptions.get("product_comment_email_notify_title"); String webMasterEmail = JPressOptions.get("web_mater_email"); if (!StrUtil.areNotEmpty(emailTemplate, emailTitle, webMasterEmail)) { return; } Map<String, Object> paras = new HashMap(); paras.put("product", product); paras.put("comment", comment); paras.put("user", user); String title = Engine.use().getTemplateByString(emailTitle).renderToString(paras); String content = Engine.use().getTemplateByString(emailTemplate).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(webMasterEmail.split(",")); email.send(); }
Example #9
Source File: JbootServiceInterfaceGenerator.java From jboot with Apache License 2.0 | 6 votes |
@Override public void generate(List<TableMeta> tableMetas) { System.out.println("Generate base model ..."); System.out.println("Base Model Output Dir: " + baseModelOutputDir); Engine engine = Engine.create("forService"); engine.setSourceFactory(new ClassPathSourceFactory()); engine.addSharedMethod(new StrKit()); engine.addSharedObject("getterTypeMap", getterTypeMap); engine.addSharedObject("javaKeyword", javaKeyword); for (TableMeta tableMeta : tableMetas) { genBaseModelContent(tableMeta); } writeToFile(tableMetas); }
Example #10
Source File: ServiceProviderGenerator.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void generate(List<TableMeta> tableMetas) { System.out.println("Generate base model ..."); System.out.println("Base Model Output Dir: " + baseModelOutputDir); Engine engine = Engine.create("forServiceImpl"); engine.setSourceFactory(new ClassPathSourceFactory()); engine.addSharedMethod(new StrKit()); engine.addSharedObject("getterTypeMap", getterTypeMap); engine.addSharedObject("javaKeyword", javaKeyword); for (TableMeta tableMeta : tableMetas) { genBaseModelContent(tableMeta); } writeToFile(tableMetas); }
Example #11
Source File: AppJbootServiceImplGenerator.java From jboot-admin with Apache License 2.0 | 6 votes |
@Override public void generate(List<TableMeta> tableMetas) { System.out.println("Generate base model ..."); System.out.println("Base Model Output Dir: " + baseModelOutputDir); Engine engine = Engine.create("forServiceImpl"); engine.setSourceFactory(new ClassPathSourceFactory()); engine.addSharedMethod(new StrKit()); engine.addSharedObject("getterTypeMap", getterTypeMap); engine.addSharedObject("javaKeyword", javaKeyword); for (TableMeta tableMeta : tableMetas) { genBaseModelContent(tableMeta); } writeToFile(tableMetas); }
Example #12
Source File: ServiceProviderGenerator.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void genBaseModelContent(TableMeta tableMeta) { Kv data = Kv.by("serviceImplPackageName", baseModelPackageName); data.set("generateChainSetter", generateChainSetter); data.set("tableMeta", tableMeta); data.set("basePackage", basePackage); data.set("modelPackage", modelPackage); Engine engine = Engine.use("forServiceImpl"); tableMeta.baseModelContent = engine.getTemplate(template).renderToString(data); }
Example #13
Source File: JfinalConfigListener.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override public void onJfinalEngineConfig(Engine engine) { engine.setDevMode(true); AppInfo app = Jboot.config(AppInfo.class); engine.addSharedObject("APP", app); engine.addSharedObject("RESOURCE_HOST", app.getResourceHost()); }
Example #14
Source File: WebInitializer.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onEngineConfig(Engine engine) { engine.addSharedFunction("/WEB-INF/views/admin/_layout/_layout.html"); engine.addSharedFunction("/WEB-INF/views/admin/_layout/_layer.html"); engine.addSharedFunction("/WEB-INF/views/admin/_layout/_errpage.html"); engine.addSharedFunction("/WEB-INF/views/admin/_layout/_paginate.html"); engine.addSharedFunction("/WEB-INF/views/ucenter/_layout/_layout.html"); engine.addSharedFunction("/WEB-INF/views/ucenter/_layout/_layout_noleft.html"); engine.addSharedStaticMethod(PermissionFunctions.class); }
Example #15
Source File: AppJbootServiceImplGenerator.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override protected void genBaseModelContent(TableMeta tableMeta) { Kv data = Kv.by("serviceImplPackageName", baseModelPackageName); data.set("generateChainSetter", generateChainSetter); data.set("tableMeta", tableMeta); data.set("basePackage", servicePackage); data.set("modelPackage", modelPacket); Engine engine = Engine.use("forServiceImpl"); tableMeta.baseModelContent = engine.getTemplate(template).renderToString(data); }
Example #16
Source File: JfinalConfigListener.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override public void onJfinalEngineConfig(Engine engine) { engine.setDevMode(true); AppInfo app = Jboot.config(AppInfo.class); engine.addSharedObject("APP", app); engine.addSharedObject("RESOURCE_HOST", app.getResourceHost()); }
Example #17
Source File: JfinalConfigListener.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override public void onJfinalEngineConfig(Engine engine) { engine.setDevMode(true); AppInfo app = Jboot.config(AppInfo.class); engine.addSharedObject("APP", app); engine.addSharedObject("RESOURCE_HOST", app.getResourceHost()); }
Example #18
Source File: EmailSender.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
/** * 用户注册时,发送邮件进行激活用户账号 * * @param user */ public static void sendForUserActivate(User user) { boolean emailValidate = JPressOptions.getAsBool("reg_email_validate_enable"); if (emailValidate == false) { return; } if (StrUtil.isBlank(user.getEmail())) { return; } AuthCode authCode = AuthCode.newCode(user.getId()); AuthCodeKit.save(authCode); String webDomain = JPressOptions.get(JPressConsts.OPTION_WEB_DOMAIN); String url = webDomain + "/user/activate?id=" + authCode.getId(); String title = JPressOptions.get("reg_email_validate_title"); String template = JPressOptions.get("reg_email_validate_template"); Map<String, Object> paras = new HashMap(); paras.put("user", user); paras.put("code", authCode.getCode()); paras.put("url", url); String content = Engine.use().getTemplateByString(template).renderToString(paras); Email email = Email.create(); email.content(content); email.subject(title); email.to(user.getEmail()); sendEmail(email); }
Example #19
Source File: JbootCoreConfig.java From jboot with Apache License 2.0 | 5 votes |
@Override public void configEngine(Engine engine) { //通过 java -jar xxx.jar 在单独的jar里运行 if (runInFatjar()) { engine.setToClassPathSourceFactory(); engine.setBaseTemplatePath("webapp"); } List<Class> directiveClasses = ClassScanner.scanClass(); for (Class clazz : directiveClasses) { JFinalDirective directive = (JFinalDirective) clazz.getAnnotation(JFinalDirective.class); if (directive != null) { engine.addDirective(AnnotationUtil.get(directive.value()), clazz); } JFinalSharedMethod sharedMethod = (JFinalSharedMethod) clazz.getAnnotation(JFinalSharedMethod.class); if (sharedMethod != null) { engine.addSharedMethod(ClassUtil.newInstance(clazz)); } JFinalSharedStaticMethod sharedStaticMethod = (JFinalSharedStaticMethod) clazz.getAnnotation(JFinalSharedStaticMethod.class); if (sharedStaticMethod != null) { engine.addSharedStaticMethod(clazz); } JFinalSharedObject sharedObject = (JFinalSharedObject) clazz.getAnnotation(JFinalSharedObject.class); if (sharedObject != null) { engine.addSharedObject(AnnotationUtil.get(sharedObject.value()), ClassUtil.newInstance(clazz)); } } JbootAppListenerManager.me().onEngineConfig(engine); }
Example #20
Source File: JbootAppListenerManager.java From jboot with Apache License 2.0 | 5 votes |
@Override public void onEngineConfig(Engine engine) { for (JbootAppListener listener : listeners) { try { listener.onEngineConfig(engine); } catch (Throwable ex) { log.error(ex.toString(), ex); } } }
Example #21
Source File: ServiceApiGenerator.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void genBaseModelContent(TableMeta tableMeta) { Kv data = Kv.by("baseModelPackageName", baseModelPackageName); data.set("generateChainSetter", generateChainSetter); data.set("tableMeta", tableMeta); data.set("modelPacket", modelPacket); data.set("basePackage", basePackage); Engine engine = Engine.use("forService"); tableMeta.baseModelContent = engine.getTemplate(template).renderToString(data); }
Example #22
Source File: JbootServiceImplGenerator.java From jboot with Apache License 2.0 | 5 votes |
public void generate(List<TableMeta> tableMetas) { System.out.println("Generate Service Impl ..."); System.out.println("Service Impl Output Dir: " + outputDir); Engine engine = Engine.create("forServiceImpl"); engine.setSourceFactory(new ClassPathSourceFactory()); engine.addSharedMethod(new StrKit()); engine.addSharedObject("getterTypeMap", getterTypeMap); engine.addSharedObject("javaKeyword", JavaKeyword.me); for (TableMeta tableMeta : tableMetas) { genBaseModelContent(tableMeta); } writeToFile(tableMetas); }
Example #23
Source File: JbootServiceImplGenerator.java From jboot with Apache License 2.0 | 5 votes |
protected void genBaseModelContent(TableMeta tableMeta) { Kv data = Kv.by("serviceImplPackageName", basePackage + "." + implName); // data.set("generateChainSetter", generateChainSetter); data.set("tableMeta", tableMeta); data.set("basePackage", basePackage); data.set("modelPackage", modelPackage); data.set("implName", implName); Engine engine = Engine.use("forServiceImpl"); tableMeta.baseModelContent = engine.getTemplate(template).renderToString(data); }
Example #24
Source File: JbootServiceInterfaceGenerator.java From jboot with Apache License 2.0 | 5 votes |
@Override protected void genBaseModelContent(TableMeta tableMeta) { Kv data = Kv.by("baseModelPackageName", baseModelPackageName); data.set("generateChainSetter", generateChainSetter); data.set("tableMeta", tableMeta); data.set("modelPacket", modelPacket); data.set("basePackage", basePackage); Engine engine = Engine.use("forService"); tableMeta.baseModelContent = engine.getTemplate(template).renderToString(data); }
Example #25
Source File: TestConfig.java From jfinal-ext3 with Apache License 2.0 | 4 votes |
@Override public void configEngineMore(Engine me) { me.setBaseTemplatePath("sql.txt"); }
Example #26
Source File: XlsConfig.java From jfinal-ext3 with Apache License 2.0 | 4 votes |
@Override public void configEngine(Engine me) { // TODO Auto-generated method stub }
Example #27
Source File: PageModuleInitializer.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onEngineConfig(Engine engine) { engine.addSharedFunction("/WEB-INF/views/commons/page/defaultPageCommentPage.html"); }
Example #28
Source File: JbootRender.java From jboot with Apache License 2.0 | 4 votes |
private Engine getEngine() { if (engine == null) { engine = RenderManager.me().getEngine(); } return engine; }
Example #29
Source File: ModuleGenerator.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
private void genPomXml() { String modulePath = basePath; String modelPath = basePath + "/module-" + moduleName + "-model"; String webPath = basePath + "/module-" + moduleName + "-web"; String serviceApiPath = basePath + "/module-" + moduleName + "-service-api"; String serviceProviderPath = basePath + "/module-" + moduleName + "-service-provider"; File modelFile = new File(modelPath); File webFile = new File(webPath); File serviceApiFile = new File(serviceApiPath); File serviceProviderFile = new File(serviceProviderPath); makeSrcDirectory(modelFile); makeSrcDirectory(webFile); makeSrcDirectory(serviceApiFile); makeSrcDirectory(serviceProviderFile); Map map = new HashMap(); map.put("moduleName", moduleName); Engine engine = new Engine(); engine.setToClassPathSourceFactory(); // 从 class path 内读模板文件 engine.addSharedMethod(new StrKit()); File modulePomXmlFile = new File(modulePath, "pom.xml"); if (!modulePomXmlFile.exists()) { engine.getTemplate("io/jpress/codegen/templates/pom_module_template.jf").render(map, modulePomXmlFile); } File modelPomXmlFile = new File(modelFile, "pom.xml"); if (!modelPomXmlFile.exists()) { engine.getTemplate("io/jpress/codegen/templates/pom_model_template.jf").render(map, modelPomXmlFile); } File webPomXmlFile = new File(webFile, "pom.xml"); if (!webPomXmlFile.exists()) { engine.getTemplate("io/jpress/codegen/templates/pom_web_template.jf").render(map, webPomXmlFile); } File serviceApiPomXmlFile = new File(serviceApiFile, "pom.xml"); if (!serviceApiPomXmlFile.exists()) { engine.getTemplate("io/jpress/codegen/templates/pom_service_api_template.jf").render(map, serviceApiPomXmlFile); } File serviceProviderPomXmlFile = new File(serviceProviderFile, "pom.xml"); if (!serviceProviderPomXmlFile.exists()) { engine.getTemplate("io/jpress/codegen/templates/pom_service_provider_template.jf").render(map, serviceProviderPomXmlFile); } }
Example #30
Source File: JPressCoreInitializer.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onEngineConfig(Engine engine) { engine.addSharedStaticMethod(JPressCoreFunctions.class); }