This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Plugins

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Packages defined in a plugin can have parent packages that are defined in another plugin. Plugins may define configuration elements with classes not contained in the plugin. Any classes not included in the plugin's JAR must be on the application's classpath at runtime. As from Struts 2.3.5

...

To include static resources in your plugins add them under "/static" in your jar. And include them in your page using "/struts" as the path, like in the following example:

...

...

Assuming /static/main.css is inside a plugin jar, to add it to the page:

<@s.url value="/struts/main.css" var="css" />
<link rel="stylesheet" type="text/css" href="%{#css}" />

Read also StaticContentLoader JavaDoc.

...

The following extension points are available in Struts 2:

Wiki Markup
{snippet:id=extensionPoints|javadoc=true|url=org.apache.struts2.config.DefaultBeanSelectionProvider}

...

Plugin Examples

Let's look at two similar but different plugins bundled with the core distribution.

...

The sitemesh-plugin.jar contains several classes, a standard JAR manifest, and a plugin configuration file.

Code Block
 + META-INF/
   + manifest.mf
 + org
   + apache
     + struts2
       + sitemesh
         + FreeMarkerPageFilter.class
         + TemplatePageFilter.class
         + VelocityPageFilter.class
 + struts-plugin.xml

...

While the SiteMesh Plugin doesn't provide any new results, interceptors, or actions, or even extend any Struts integration points, it does need to know what settings have been enabled in the Struts framework. Therefore, its struts-plugin.xml looks like this:

Wiki Markup
{snippet:id=all|lang=xml|url=struts2/plugins/sitemesh/src/main/resources/struts-plugin.xml}

...

The two bean elements, with the "static" flag enabled, tell Struts to inject the current settings and framework objects into static property setters on startup. This allows, for example, the FreeMarkerPageFilter class to get an instance of the Struts FreemarkerManager and the current encoding setting.

...

The tiles-plugin.jar contains several classes, a standard JAR manifest, and a configuration file.

Code Block
 + META-INF/
   + manifest.mf
 + org
   + apache
     + struts2
       + tiles
         + StrutsTilesListener.class
         + StrutsTileUtilImpl.class
       + views
         + tiles
           + TilesResult.class
   + struts-plugin.xml

...

Since the Tiles Plugin does need to register configuration elements, a result class, it provides a struts-plugin.xml file.

...