ZK Developer's Guide
ZK Developer's Guide
ZK Developer's Guide
- TAGS
- guide
- iknow.seforge.org
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Integration with Other Frameworks<br />
So, with all these advantages, it's no wonder that Spring is one of the most used<br />
frameworks. Spring provides many nice features: however, it works mainly in the<br />
back end. Here <strong>ZK</strong> may provide support in the view layer. The benefit from this<br />
pairing is the flexible and maturity of Spring together with the easy and speed of<br />
<strong>ZK</strong>. Specify a Java class in the use attribute of a window ZUL page and the world of<br />
Spring will be yours. Remember as discussed in previous chapters what a sample<br />
ZUL looks I like:<br />
<br />
<br />
Thank you for using our Hello World Application.<br />
<br />
The HelloController points directly to a Java class where you can use Spring<br />
features easily.<br />
Normally, if a Java Controller is used for a ZUL page it becomes necessary<br />
sooner or later to call a Spring bean. Usually in Spring you would use the<br />
applicationContext like:<br />
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");<br />
UserDAO userDAO = (UserDAO) ctx.getBean("userDAO");<br />
Then the userDAO is usable for any further access. In <strong>ZK</strong> there is a helper class<br />
SpringUtil. It wrapps the applicationContext and simplifies the code to:<br />
UserDAO userDAO = (UserDAO) SpringUtil.getBean("userDAO");<br />
Pretty easy, isn't it? Let us examine an example.<br />
Assume we have a small web application that gets flight data from a flight table. The<br />
web.xml file looks like:<br />
<br />
<br />
[ 126 ]