Quickstart guide

Print



Only two files need to be edited in order to use JavAjax in your application: deployment descriptor (web.xml) and the properties file used for internationalization.

Deployment Descriptor (web.xml)

Filter net.sourceforge.javajax.JavajaxFilter

Parameters

:

  • resource.file (required): relative path 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"
  • security.manager: The security manager class, implementing net.sourceforge.javajax.security.JavajaxSecurityManager, that will be used to check security constraint at method level. You can find a default implementation net.sourceforge.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

Mapping:

  • *.{page.extension}
  • *.{ajax.extension}
  • *.jsp

 

Here is a basic configuration ready to be included in your web.xml file:


<filter>
<filter-name>JavAjaxFilter</filter-name>
<filter-class>net.sourceforge.javajax.JavajaxFilter</filter-class>
<init-param>
<param-name>action.packages</param-name>
<param-value>demo.actions</param-value>
</init-param>

<init-param>
<param-name>resource.file</param-name>
<param-value>resources/javajax</param-value>
</init-param>

<!-- Optional parameter, default is "page"
<init-param>
<param-name>page.extension</param-name>
<param-value>page</param-value>
</init-param>
-->
<!-- Optional parameter, default is "ajax"
<init-param>
<param-name>ajax.extension</param-name>
<param-value>page</param-value>
</init-param>
-->
<!-- Optional parameter, default is "error.jsp"
<init-param>
<param-name>error.page</param-name>
<param-value>error.jsp</param-value>
</init-param>
-->
<!-- Optional parameter
<init-param>
<param-name>date.formats</param-name>
<param-value>dd MMM yyyy | yyyy-MM-dd | dd-MM-yyyy | ddd, dd MMM yyyy</param-value>
</init-param>
-->
<!-- Optional parameter
<init-param>
<param-name>conversion.locale</param-name>
<param-value>en-US</param-value>
</init-param>
--> <!-- Optional parameter
<init-param>
<param-name>security.manager</param-name>
<param-value>net.sourceforge.javajax.security.J2EESecurityManager</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>*.jsp</url-pattern>
</filter-mapping>



Resource file

Create a property file and place it in the same directory and with the same name specified in the JavajaxFilter init param, with at least the following properties:


# ERROR PLACEHOLDERS: LIST TYPE
net.sourceforge.javajax.error.list.start.tag=<UL class='errorList' name='fullErrorList'>
net.sourceforge.javajax.error.list.end.tag=</UL>
net.sourceforge.javajax.error.list.line.start.tag=<LI class='errorLine'>
net.sourceforge.javajax.error.list.line.end.tag=</LI>

# ERROR PLACEHOLDERS: BLOCK TYPE
net.sourceforge.javajax.error.block.start.tag=<SPAN class='errorContainer' name='{0}'>
net.sourceforge.javajax.error.block.end.tag=</SPAN>
net.sourceforge.javajax.error.block.line.start.tag=<SPAN class='errorLine'>
net.sourceforge.javajax.error.block.line.end.tag=</SPAN>

# GENERIC SYSTEM ERROR
net.sourceforge.javajax.systemerror=System error: [{1}] {2}

# EXPRESSION ANNOTATION INVALID ERROR
net.sourceforge.javajax.invalid.expression=The following expression is not valid: {1}. It must return a boolean value

# METHOD ACCESS SECURITY ERROR
net.sourceforge.javajax.securityerror=Security error: User [{1}] does not have rights to access method {2} in class {3}

# VALIDATION MESSAGES
net.sourceforge.javajax.invalid.format=Field {0} has an invalid format
net.sourceforge.javajax.mandatory=Field {0} is mandatory
net.sourceforge.javajax.too.short=Field {0} is too short, minimum length is {1}
net.sourceforge.javajax.too.long=Field {0} is too long, maximum length is {1}
net.sourceforge.javajax.too.low=Field {0} value is too low, minimum value is {1}
net.sourceforge.javajax.too.large=Field {0} value is too high, maximum value is {1}
net.sourceforge.javajax.expression.verification.failed=The following expression verification failed: {1}



JavAjax framework requires the following libraries to work properly:

http://commons.apache.org/

  • commons-fileupload.jar
  • commons-jexl.jar
  • commons-logging.jar

http://www.prototypejs.org/

  • prototype.js