Zscript to MVC Extractor"

From Documentation
Line 7: Line 7:
  
 
{{ZKStudioEssentialsPageFooter}}
 
{{ZKStudioEssentialsPageFooter}}
 +
 +
Before
 +
<source lang="xml">
 +
<window id="win" >
 +
<button id="btn" onClick='alert("aaa");' />
 +
<button id="att">
 +
<attribute name="onClick">
 +
<![CDATA[
 +
alert("bbb");
 +
]]>
 +
</attribute>
 +
</button>
 +
</window>
 +
</source>
 +
 +
After
 +
<source lang="xml">
 +
<window id="win" >
 +
<button id="btn"  />
 +
<button id="att">
 +
</button>
 +
</window>
 +
</source>
 +
 +
<source lang="java">
 +
import org.zkoss.zk.ui.Component;
 +
import org.zkoss.zk.ui.util.GenericForwardComposer;
 +
import org.zkoss.zul.Button;
 +
import org.zkoss.zul.Window;
 +
 +
public class WinViewCtrl extends GenericForwardComposer {
 +
 +
private Window win;
 +
private Button att;
 +
private Button btn;
 +
 +
@Override
 +
public void doAfterCompose(Component comp) throws Exception {
 +
super.doAfterCompose(comp);
 +
// TODO Auto-generated method stub
 +
 +
}
 +
 +
public void onClick$att() {
 +
//TODO: please check if you have use "self" or zscript functions here.
 +
 +
alert("bbb");
 +
 +
}
 +
 +
public void onClick$btn() {
 +
//TODO: please check if you have use "self" or zscript functions here.
 +
alert("aaa");
 +
}
 +
 +
}
 +
</source>

Revision as of 08:29, 6 December 2010

Zscript to MVC Extractor



Introduction

For better architecture and future maintainence, it's better to follow MVC pattern to implement a web application. The extractor helps you to refactor a ZUL with Zscript to MVC way by the rules mentioned in the smalltalk: ZK MVC Made Easy.

Step by Step

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.


Before

<window id="win" >
	<button id="btn" onClick='alert("aaa");' />
	<button id="att">
		<attribute name="onClick">
		<![CDATA[
			alert("bbb");
		]]>
		</attribute>
	</button>
</window>

After

<window id="win" >
	<button id="btn"  />
	<button id="att">		
	</button>
</window>
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Window;

public class WinViewCtrl extends GenericForwardComposer {

	private Window win;
	private Button att;
	private Button btn;

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		// TODO Auto-generated method stub

	}

	public void onClick$att() {
		//TODO: please check if you have use "self" or zscript functions here.

		alert("bbb");

	}

	public void onClick$btn() {
		//TODO: please check if you have use "self" or zscript functions here.
		alert("aaa");
	}

}