Set up and configuration
Only three files need to be edited in order to use JavAjax in your application: deployment descriptor (web.xml), the properties file used for localization and eventually javajax.js script.
- web.xml: Filter configuration
The JavAjax Filter must be configured, class is org.thinkjava.javajax.JavajaxFilter
Filter init Params:
- resource.file (required): path (relative to WEB-INF/classes) and file base name of the resource bundle property file
- action.packages (required): The package or list of packages where the framework should look for available actions in your application
- page.extension: The URL extension used for page type calls. Default is "page"
- ajax.extension: The URL extension used for ajax type calls. Default is "ajax"
- js.extension: The URL extension used to obtain the javascript code related to an action. Default is "ajs"
- security.manager: The security manager class, implementing org.thinkjava.javajax.security.JavajaxSecurityManager,
that will be used to check security constraint at method level.
You can find a default implementation org.thinkjava.javajax.security.J2EESecurityManager, which checks method specific security constraints among current user roles. - conversion.locale: Application level Locale used for data conversion. Default is the user browser default Locale
- date.formats: Pipe separated list of accepted date formats, used during conversion.
- error.page: context relative path to the page used to display errors. Default is /error.jsp
- wordwrapJSCode: specifies if JS Action interface code should contain indentation or generated on a single line.
- custom.validators: comma separated list of custom Validator classes.
- custom.converters: comma separated list of custom Converter classes.
- custom.formatters: comma separated list of custom Formatter classes, in the format {managedType}|{FormatterClass}.
- action.visitors: comma separated list of ActionVisitor classes.
- springinjector.config.file: If Spring Injection framework is needed, this parameter specifies the location of the spring configuration xml file.
- ajax.default.encoding: Default enconding used with a JSON response. Default is UTF-8.
Filter Mapping:
- *.{page.extension}
- *.{ajax.extension}
- *.{js.extension}
- *.jsp
Basic configuration example
<filter>
<filter-name>JavAjaxFilter</filter-name>
<filter-class>org.thinkjava.javajax.JavajaxFilter</filter-class>
<init-param>
<param-name>action.packages</param-name>
<param-value>action, actions, web.actions</param-value>
</init-param>
<init-param>
<param-name>resource.file</param-name>
<param-value>resources/javajax</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>JavAjaxFilter</filter-name>
<url-pattern>*.page</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>JavAjaxFilter</filter-name>
<url-pattern>*.ajax</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>JavAjaxFilter</filter-name>
<url-pattern>*.ajs</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>JavAjaxFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
- Properties file (javajax.properties)
This file contains the "framework level" properties to manage and localize error messages and the display style.
The properties can be edited to match your application specific style. For detailed info, please read the default javajax.properties file you can find in the distribution.
- javajax.js / javajax_jquery.js
This file only needs to be edited in the first row, to specify the js extension, as configured in web.xml. If it was not configured (leaving the default value "ajs"), no change is needed.