
Example For Custom Plugins :-
(1) Creating the Plugin Class
The struts provide org.apache.struts.action.PlugIn interface. All the custom Plugin should implement the PlugIn interface and override the init() and destroy() methods.
package com.visualbuilder.plugin;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
public class CustomPlugin implements PlugIn {
public CustomPlugin() {
super();
}
public void destroy() {
System.out.println("The plug in Destroyed");
}
public void init(ActionServlet controller, ModuleConfig config) throws ServletException {
controller.getServletContext().setAttribute("testPlugin","Testing for the object");
System.out.println("The plug in initialized");
}
}
(2) Struts-config.xml file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- ================================================ Form Bean Definitions -->
<form-beans></form-beans>
<!-- ========================================= Global Exception Definitions -->
<global-exceptions></global-exceptions>
<!-- =========================================== Global Forward Definitions -->
<global-forwards></global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<action path="/plugin"
type="com.visualbuilder.TestPluginAction"
input="/index.jsp" >
<forward name="SUCCESS" path="/index.jsp"/>
</action>
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="MessageResources" />
<!-- ======================================== Custom Plugin Definitions -->
<plug-in className="com.visualbuilder.plugin.CustomPlugin"></plug-in>
</struts-config>
Jsp Discussion
- - Two forms in one JSP
- - PASS VARIABLES BETWEEN 2
- - Table data
- - Unable to laod the image
- - The Ultimate Web UI Frame




