Using the Custom Controller
This description is based on the assumption that:
-
You have written the class
com.escenic.framework.controller.impl.CustomController
, which extends the classcom.escenic.framework.controller.AbstractController
. -
This class is in a separate Maven module and packaged in a jar file.
-
You want to use this class as the controller for one of the standard widgets.
To make use of the class you have written:
-
Make sure that the Maven module for the custom controller contains a
.properties
file calledCustomController.properties
in the folder/src/main/resources/com/escenic/servlet/default-config/com/escenic/framework/controller/impl
. The file must have the following contents:$class=com.escenic.framework.controller.impl.CustomController
-
Run:
mvn clean install
in the Maven module folder. This will generate a
.jar
file and install it in your local repository. -
Download and extract the Widget Framework Core distribution.
-
Choose one of the core widgets for modification - the
code
widget for example. -
Create a
.properties
file calledControllerFactory.properties
in thewidget-core-code/src/main/resources/com/escenic/servlet/default-config/com/escenic/framework/controller/factory
folder. -
Open
ControllerFactory.properties
for editing and enter the following:controller.code=/com/escenic/framework/controller/impl/CustomController
-
Change directory to the distribution's
misc/widgets
folder. -
Run the following command.
mvn clean install
-
Change directory to the distribution's
misc/demo
folder. -
Open
pom.xml
for editing. -
Add a dependency to the
.jar
file containing the custom controller and relevant configuration files. The dependency must be added in compile scope to ensure that the.jar
file containing the custom controller is present inWEB-INF/lib
folder ofdemo.war
after the build. -
Run:
mvn clean install
During the build, all the
ControllerFactory.properties
files in various modules will be merged. The merged file will contain the line that you added to theControllerFactory.properties
file for thecode
widget. -
Deploy the
demo.war
webapp created inmisc/demo/target
.