Skip to content

mehah/jRender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jRender

It's a library that allows Java to manipulate DOM, exactly like Javascript, using object orientation and language typing Java. Render and validate your application with more security and performance

Security: All of its logic, as well as rendering and validation, can be performed inside the server, this way we hide code.

Performance: The client-server communication is done with JSON, with this we have fewer bytes passing, which can be accomplished with either ajax, iframe or websocket.

JavaScript frameworks: As the library allows interac with Dom, then it will have access to any framework created for Javascript, but to let the writing more close to Javascript, it will be necessary to create plug-ins, for example : jQuery, jQueryUI and Vue.js.

Min. Requirements

Javascript Cross-Browser Lib Support

Example

Small example of visitor counts.

index.html

<html>
	<body>
		Amount of people that had seen this page: <span id="count"></span>
	</body>
</html>

IndexController.java

@Page(name="index", path="index.html")
public class IndexController extends Window {
	private static int VISITORS_COUNT = 0;
	
	public void init(JRenderContext arg0) {
		document.getElementById("count").textContent((++VISITORS_COUNT)+"");		
	}
}

OR

Real time visitor count, so that a refresh page isnt necessary.

@Page(name="index", path="index.html")
public class IndexController extends Window {	
	private static int VISITORS_COUNT = 0;
	
	private final Element spanCount = document.getElementById("count");
	
	private int lastCount;
	
	public void init(JRenderContext context) {		
		spanCount.textContent((++VISITORS_COUNT)+"");
		
		this.lastCount = VISITORS_COUNT;
		setInterval(new FunctionHandle("realTimeUpdate"), 1000);
	}
	
	public void realTimeUpdate() {
		if(this.lastCount != VISITORS_COUNT) {
			this.lastCount = VISITORS_COUNT;
			spanCount.textContent(VISITORS_COUNT+"");
		}
	}
}

Understand:

More examples: