Machine Learning Authors: Zakia Bouachraoui, Liz McMillan, Pat Romanski, William Schmarzo, Yeshim Deniz

Related Topics: Java IoT, Machine Learning

Java IoT: Tutorial

Developing MVC Applications Using ZK and Spring

MVC app with ZK and Spring

The ZK framework provides a variety of paradigms to develop Web applications. One the one hand it is always nice to have options, but on the other this can cause un-intentional paradigm disparities when several developers are using the framework to develop an application without a consistent design.

By and far, Model View Controller pattern has been adapted by various  Web applications and frameworks (like Apache Struts, Apache Beehive PageFlows)  to develop quality Web applications.

The following is an illustration of how an MVC based Web application can be developed using ZK and Spring. ZK has introduced a lot of features that enable easy integration with Spring. The source code of example application is available for download here.

The Model:
The model is usually an object or a group of objects representing a business entity. In this example, an object called UserProfile is designed to represent a user. It is defined declaratively per EJB 3 standards.

The View:
The zul page, userProfile.zul is a the page that acts as a view that provides information to the user.

The Controller:
ZK provides a convenience feature use Spring beans with minimal code. All spring beans can be accessed by their names as long as a zul page has the following declaration:

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>

With this declaration, any Spring bean can be accessed by its name. For example, the following zscript scriptlet accesses a Spring bean UserProfileController using its name.

import com.example.userprofile.controller.UserProfileController;
UserProfileController controller = userProfileController;

Note that ‘userProfileController’ is the name of the Spring bean per its declaration
public class UserProfileController {


The annotation ‘Scope’ defines scope and lifecycle of a Spring bean. By default all Spring beans are Singletons. When declared as of type ‘prototype’, Spring generates the bean objects using a factory pattern. So each call made in zscript on page render gets a new object instance, thus making sure that every user gets a new object whose life span is that of the zul page itself. Using Spring MVC framework, further options are available to specify session scoped controllers.

More Stories By Srinivas Jaini

Srinivas Jaini is a software technologist with extensive experience in developing enterprise software applications.

CloudEXPO Stories
@CloudEXPO and @ExpoDX, two of the most influential technology events in the world, have hosted hundreds of sponsors and exhibitors since our launch 10 years ago. @CloudEXPO and @ExpoDX New York and Silicon Valley provide a full year of face-to-face marketing opportunities for your company. Each sponsorship and exhibit package comes with pre and post-show marketing programs. By sponsoring and exhibiting in New York and Silicon Valley, you reach a full complement of decision makers and buyers in multiple vertical markets. Our delegate profiles can be located in our show prospectus.
In today's always-on world, customer expectations have changed. Competitive differentiation is delivered through rapid software innovations, the ability to respond to issues quickly and by releasing high-quality code with minimal interruptions. DevOps isn't some far off goal; it's methodologies and practices are a response to this demand. The demand to go faster. The demand for more uptime. The demand to innovate. In this keynote, we will cover the Nutanix Developer Stack. Built from the foundation of software-defined infrastructure, Nutanix has rapidly expanded into full application lifecycle management across any infrastructure or cloud .Join us as we delve into how the Nutanix Developer Stack makes it easy to build hybrid cloud applications by weaving DBaaS, micro segmentation, event driven lifecycle operations, and both financial and cloud governance together into a single unified st...
"Cloud computing is certainly changing how people consume storage, how they use it, and what they use it for. It's also making people rethink how they architect their environment," stated Brad Winett, Senior Technologist for DDN Storage, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
Sold by Nutanix, Nutanix Mine with Veeam can be deployed in minutes and simplifies the full lifecycle of data backup operations, including on-going management, scaling and troubleshooting. The offering combines highly-efficient storage working in concert with Veeam Backup and Replication, helping customers achieve comprehensive data protection for all their workloads — virtual, physical and private cloud —to meet increasing business demands for uptime and productivity.
While the focus and objectives of IoT initiatives are many and diverse, they all share a few common attributes, and one of those is the network. Commonly, that network includes the Internet, over which there isn't any real control for performance and availability. Or is there? The current state of the art for Big Data analytics, as applied to network telemetry, offers new opportunities for improving and assuring operational integrity. In his session at @ThingsExpo, Jim Frey, Vice President of Strategic Alliances at Kentik, discussed tactics and tools to bridge the gap between IoT project teams and the network planning and operations functions that play a significant role in project success.