-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangbiao
committed
Oct 30, 2019
1 parent
2bd2906
commit f128a0d
Showing
6 changed files
with
328 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/jflyfox/component/beelt/JFinalBeetlRender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.jflyfox.component.beelt; | ||
|
||
import com.jfinal.render.Render; | ||
import org.beetl.core.GroupTemplate; | ||
import org.beetl.ext.web.WebRender; | ||
|
||
/** | ||
* beetl render | ||
* | ||
* @author jflyfox | ||
* @date 2019/10/30 | ||
*/ | ||
public class JFinalBeetlRender extends Render { | ||
GroupTemplate groupTemplate; | ||
|
||
public JFinalBeetlRender(GroupTemplate groupTemplate, String view) { | ||
super.setView(view); | ||
this.groupTemplate = groupTemplate; | ||
} | ||
|
||
@Override | ||
public void render() { | ||
this.response.setContentType("text/html; charset=" + getEncoding()); | ||
WebRender web = new WebRender(this.groupTemplate); | ||
web.render(this.view, this.request, this.response, (Object[])null); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/jflyfox/component/beelt/JFinalBeetlRenderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.jflyfox.component.beelt; | ||
|
||
import com.jfinal.kit.PathKit; | ||
import com.jfinal.render.Render; | ||
import com.jfinal.render.RenderFactory; | ||
import org.beetl.core.Configuration; | ||
import org.beetl.core.GroupTemplate; | ||
import org.beetl.core.ResourceLoader; | ||
import org.beetl.core.resource.WebAppResourceLoader; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* beetl render factory | ||
* | ||
* @author jflyfox | ||
* @date 2019/10/30 | ||
*/ | ||
public class JFinalBeetlRenderFactory extends RenderFactory { | ||
public GroupTemplate groupTemplate = null; | ||
|
||
public JFinalBeetlRenderFactory() { | ||
} | ||
|
||
@Override | ||
public Render getRender(String view) { | ||
return new JFinalBeetlRender(this.groupTemplate, view); | ||
} | ||
|
||
public void config() { | ||
String root = PathKit.getWebRootPath(); | ||
WebAppResourceLoader resourceLoader = new WebAppResourceLoader(root); | ||
this.config(resourceLoader); | ||
} | ||
|
||
public void config(String root) { | ||
WebAppResourceLoader resourceLoader = new WebAppResourceLoader(root); | ||
this.config(resourceLoader); | ||
} | ||
|
||
public void config(ResourceLoader rs) { | ||
if (this.groupTemplate != null) { | ||
this.groupTemplate.close(); | ||
} | ||
|
||
try { | ||
Configuration cfg = Configuration.defaultConfiguration(); | ||
this.groupTemplate = new GroupTemplate(rs, cfg); | ||
} catch (IOException var3) { | ||
throw new RuntimeException("加载GroupTemplate失败", var3); | ||
} | ||
} | ||
} |
Oops, something went wrong.