Monday, May 26, 2014
HybridJava and Spring
Thursday, January 23, 2014
HybridJava vs. Wicket
Wednesday, January 1, 2014
HybridJava Challenge
The HybridJava Challenge
Comparison
of Web frameworks is a difficult task. Even if we limit ourselves to the Java
world server-side presentation layer we find dozens of frameworks. But what is a
good framework? A freshman student and a software company may have different criteria.
Let
me introduce a small example of a dynamic page implemented using HybridJava
framework. The challenge is for other frameworks (JSF, Spring,
etc.) to implement the same page AND demonstrate same convenience, conciseness
and performance.
In
HybridJava adding components to a page or to another
component is as simple as inserting tags and requires no programming or
configuration. So in
our example we create a simple component that has a Submit button and counts
the number of times the button was pushed. The framework supports server-side
event propagation trough the component tree. We insert 12 such components into
the page (file Components.page) :
<html>
<EventLog>
<HJForm>
<table border="3" cellpadding="5">
<ForI n=3>
<tr>
<ForJ n=4>
<td><Component/></td>
</ForJ>
</tr>
</ForI>
</table>
</HJForm>
</EventLog> // renders
events from inner components
</html>
The
screenshot of this page:
And
here is the component which is a pair of markup + Java class:
Component.widget
<widget name=Component>
<div align="center"><HJRadio checked=${!flag} verb="toggle" value="off"/>
<HJRadio checked=flag verb="toggle" value="on"/></div>
<B> $count </B><HJButton/>
</widget>
Component.java
package com.HybridJava.Challenge;
import com.HybridServerPages.BaseComponent;
public class Component_WS extends BaseComponent {
int count;
boolean flag = false; // current state
private boolean prev_flag = false;
@Override protected void $handleComponent(String h1,String h2){
String value = $getParam("toggle",flag ? "on" : "off");
if(value.equals("on"))
flag
= true;
if(value.equals("off"))
flag
= false;
if(flag != prev_flag){
$send(2,"Flag " + flag, null);
}
prev_flag
= flag;
if(h1.length()==0)
return;
count++;
$send(1,"Pushed",null);
}
}
As
a matter of fact – file Challenge.war is 34
kilobytes.