Using the Custom Controller
Let us suppose that we have written the class
com.escenic.framework.controller.impl.CustomController
which extends the class
com.escenic.framework.controller.AbstractController
.
Let us also assume that this class is in a separate maven module and
packaged in a jar file. We now want to use this class as the controller
for one of the standard widgets. In the following paragraphs, we will
describe how to do so in the context of the Widget Framework Core
distribution.
-
Please ensure that the maven module for the custom controller contains a properties file named CustomController.properties in the folder /src/main/resources/com/escenic/servlet/default-config/com/escenic/framework/controller/impl. The content of the file will be as follows :
$class=com.escenic.framework.controller.impl.CustomController
-
Run
mvn clean install
command in the custom maven module so that the jar file is created and installed in your local repository. -
Download and extract
Widget Framework Core
distribution. Go tomisc/widgets
folder. -
Choose one of the core widgets for modification. For the sake of discussion, let us suppose that we have chosen the 'ad' widget.
-
Create a properties file named
ControllerFactory.properties
in thewidget-core-ad/src/main/resources/com/escenic/servlet/default-config/com/escenic/framework/controller/factory
folder. The contents of the file will be as follows :controller.ad=/com/escenic/framework/controller/impl/CustomController
-
Run
mvn clean install
command inmisc/widgets
folder. -
Then go to
misc/demo
folder. Edit the pom.xml file in that folder and add the dependency to the jar file that contains the custom controller and relevant configuration files. The dependency should be added in compile scope to ensure that the jar file containing the custom controller is present inWEB-INF/lib
folder of the demo war after the build. -
Run
mvn clean install
command inmisc/demo
folder. During the build, all theControllerFactory.properties
files in various modules will be merged. The merged file will contain the line that we placed in theControllerFactory.properties
file specific to the 'ad' widget. -
Deploy the demo webapp war file that is created in
misc/demo/target
folder.