|
Frequently Asked Questions
|
|
Our FAQs are divided into the following sections:
|
- General
- What are the licensing arrangements for PAJES?
- What are the minimum requirements for using PAJES?
- Can I use PAJES in Java 1.1.x environments?
- Support
- What are the support arrangements for PAJES?
- Presentation Framework
- What is a PAJE?
- Do I have to recompile or restart my web application to detect changes to my HTML source files?
- Can I use the PAJES HTML objects directly, without using HTML template files?
- Sometimes I need to be able to hide an HTML element. How can I do that?
- How do I internationalise my application?
- Can I turn off automatic internationalisation checking?
- How do I validate user input on my HTML Form?
- What built-in client validation is available in PAJES?
- How do I send compressed content back to the browser?
- I just need to parse and manipulate some HTML, but not in a servlet. Can I do that?
- Servlet Framework
- How do I access a file uploaded using a multi-part HTTP request in my servlet?
- Why do I get "
HTTP ERROR: 413 Request Entity Too Large" when uploading a file?
- Can I encrypt query strings so that users cannot see what parameters are being passed?
- Jenerator
- Why does the Jenerator generate so many classes?
|
|
|
|
Q. What are the licensing arrangements for PAJES?
|
|
The license basically says that
PAJES can be used in both free and commercial projects with
full source code and at no charge, as long as the simple copyright
requirements are met.
|
|
Q. What are the minimum requirements for using PAJES?
|
The Presentation Framework requires:
- Java 2 (API 1.2+)
- Servlet API 2.2+
The Servlet Framework requires:
- Java 2 (API 1.2+)
- Servlet API 2.3+
- JDOM for accessing, manipulating, and outputting XML data
|
|
Q. Can I use PAJES in Java 1.1.x environments?
|
|
Sorry, but no, it won't work. It uses collections and other Java 2
features.
|
|
|
|
Q. What are the support arrangements for PAJES?
|
|
Informal support, bug reports and features requests should all be
submitted to the Support Mailing List.
|
|
Viridian, the original
developers of PAJES, also offers commercial support agreements.
|
|
|
Presentation Framework
|
Top
|
|
|
Q. What is a PAJE?
|
|
A Paje is a Java class
that represents an HTML page.
|
|
The org.pajes.html
package contains over 90 classes for acccessing and manipulating all
elements of an HTML page.
|
|
Q. Do I have to recompile or restart my web application to detect
changes to my HTML source files?
|
|
No. PAJES will detect file modifications automatically, although you
can turn this off if you want to (which means that you then would have
to restart to detect changes).
|
|
Q. Can I use the PAJES HTML objects directly, without using HTML
template files?
|
Sure you can. Look at this example code snippet:
Paje doc = new Paje();
Paragraph para = new Paragraph("Hello World");
doc.getHead().setPageTitle("Hello World Page");
doc.getBody().add(para);
doc.write(this.getServletContext(), request, response);
Drop this code in the doGet method of your servlet, and
you are done.
|
|
Q. Sometimes I need to be able to hide an HTML element. How can I
do that?
|
Almost every class in the org.pajes.html
package inherits from Tag,
which has a method called setWritable(boolean).
Just simply call this method with a value of false, and
the element will not be returned to the browser.
|
|
Alternatively, every class in the org.pajes.html
package implements setWritePermission(org.pajes.security.WritePermission, String, String).
This is the PAJES security mechanism, and can be applied to any
HTML or text element on the Paje. To use it, you define an
implementation of org.pajes.security.WritePermission,
and then apply it to the relevant objects. If the implementation
(which is usually a Singleton, for performance reasons)
determines that the current user can see the element, it will be
written back to the browser (if it is writable, of course). If they
shouldn't see it, then they won't. It is that simple....
|
|
Q. How do I internationalise my application?
|
|
Pajes automatically detects the browser's preferred language settings,
and attempts to locate an alternate HTML page, using standard Java
conventions.
|
For example, if you have a base document called menu.html,
and a user from Mexico logs into your site, the PajeFactory
will attempt to locate a source HTML file called menu_es_MX.html. If
it doesn't exist, it will then try menu_es.html, and if that
doesn't exist, it will send the base page. If an internationalised
page is found, it will be cached to ensure optimal performance.
|
|
Q. Can I turn off automatic internationalisation checking?
|
|
Yes, although we usually don't as the overhead is negligible.
|
|
You can turn off internationalisation checking for a particular
PajeFactory
by calling setInternationalisationChecking(false).
|
Alternatively, you can change the default for all PajeFactory objects
by placing the following in your web application deployment descriptor
(web.xml):
<context-param>
<param-name>org.pajes.html.PajeFactory.i18nChecking</param-name>
<param-value>false</param-value>
</context-param>
|
|
Q. How do I validate user input on my HTML Form?
|
|
Pajes contains a set of sophisticated JavaScript based client
validation functions. The Java representations of these are found in the
org.pajes.html.validation
package.
|
|
All classes in the org.pajes.html
package that represent HTML input,
elements, have a method called addClientValidation(ValidationFunction).
Multiple validation functions may be added to a single input element.
Once the validation has been added to the input element, no further
action is required by the developer.
|
|
There is also a convenience method on classes that represent input
fields
called setMandatory(boolean)
that will automatically add IsMandatory
validation.
|
|
Q. What built-in client validation is available in PAJES?
|
| Function |
Description |
| IsBetween |
Checks that the user has entered a value within a specified range. |
| IsCreditCard |
Checks that the user has entered a valid credit card number. |
| IsDecimal |
Checks that a value that the user has entered is a valid number, with the specified number of decimal places. |
| IsEmailAddress |
Checks that the user has entered a valid email address. |
| IsEqual |
Checks that the user has entered the same value twice correctly. |
| IsFormat |
Checks that the user has entered a value in a format specified by a mask. Used for date validation checking, and any other formatted values. |
| IsInteger |
Checks that the value entered by the user is a valid integer |
| IsLength |
Checks that the value entered by the user has a specified number of characters, or is within a specified range. |
| IsSelected |
Checks that the user has selected a valid value from a list. |
| IsValid |
Checks that the value entered by the user is one of a specified set of values. |
|
|
Q. How do I send compressed content back to the browser?
|
|
You can turn on compression for a particular Paje
by calling useCompression(true).
|
Alternatively, you can change the default for all Pajes by placing the
following in your web application deployment descriptor (web.xml):
<context-param>
<param-name>org.pajes.servlet.Browser.useCompression</param-name>
<param-value>true</param-value>
</context-param>
|
|
Q. I just need to parse and manipulate some HTML, but not in a servlet. Can I do that?
|
You can use the PajeParser directly, and then
use it's toPaje() method to create a
Paje. Then you you just do whatever manipulation
you need, using standard PAJES methods and objects. When you have finished, you can get the
HTML document as a String using the toString() on the Paje object.
|
For example:
File file = new File("test.html");
PajeParser parser = new PajeParser(file);
Paje doc = parser.toPaje();
Tag[] anchors = doc.getTagByClass(Anchor.class);
for (int i = 0; i < anchors.length; i++) {
Anchor anchor = (Anchor)anchors[i];
anchor.setURL("asdf");
}
System.out.print(doc.toString());
|
|
Be careful, though: it is more efficient to create a PajeFactory
if you want to get and manipulate mulitple copies of the same HTML source file, rather than re-parsing
the file each time you want to do something.
|
|
|
|
Q. How do I access a file uploaded using a multi-part HTTP request in
my servlet?
|
Your servlet must extend PajeServlet
or one of its sub-classes, and you just use the following methods:
getUploadedFileNames(HttpServletRequest request)
getUploadedFile(HttpServletRequest request, String sourceFileName)
|
Q. Why do I get "HTTP ERROR: 413 Request Entity Too Large"
when uploading a file?
|
|
This is a security measure designed to help prevent Denial of Service
attacks by uploading extremely large files. The default maximum size
is 1,048,510 bytes.
|
|
You can change the default for a particular PajeServlet
by calling the setMaxFileUploadSize(int)
method in your servlet initialisation.
|
Alternatively, you can change the default for all servlets by placing
the folliwng in your web application deployment descriptor (web.xml):
<context-param>
<param-name>org.pajes.servlet.Browser.maxFileUploadSize</param-name>
<param-value>1048510</param-value>
</context-param>
|
|
Q. Can I encrypt query strings so that users cannot see what parameters
are being passed?
|
You can turn on query string parameter encryption by placing the
following in your web application deployment descriptor (web.xml):
<context-param>
<param-name>org.pajes.servlet.Browser.useEncryptedQueryParameters</param-name>
<param-value>true</param-value>
</context-param>
|
|
|
|
Q. Why does the Jenerator generate so many classes?
|
|
The Jenerator creates both an abstract and a concrete class for
almost everything it does. This enables you to separate the Jenerated
code from the program code you have to write.
|
|
You should never change the Jenerated abstract classes.
Only ever write code in the concrete classes, and re-Jenerate the
abstract classes as needed.
|
|
For example, if you write some code that manipulates the HTML
Jenerated from your source document, and then your source document
changes so significantly that it has to be re-Jenerated, you only
need to recreate the abstract PajeTemplate and Paje sub-classes, and
your hand developed code in your concrete class will not be lost.
|