Summary: Use Java Applets in PmWiki pages
Version: 2007-12-05
Status: Stable
Prerequisites: pmwiki-2.0.beta26
Description
The applet.phpΔ script provides an (:applet:) markup to handle this.
Proceed to installation steps as usual for cookbook recipe scripts.
Notes
Java Applet Installation
- Put the java applet files (usually .class hierarchies or .jar) into
pub/applets subdirectory (that you may need to create).
- If required, extra subdirectories may be used to separate several applets.
Markup usage
Once installed, the following markup is available:
(:applet PARAMETERS... :)
with the following parameters:
code=CLASS- The applet entry point class (required).
width=..., height=...- The applet geometry (required).
archive=JAR- The applet jar archive name (optional, to be used if the applet is provided as an archive).
codebase=SUBDIRECTORY- The extra subdirectory specification needed to reach the applet (optional, the trailing slash is required).
All other supplied parameters are forwarded to the selected applet:
MY.PARAM=MY_VALUE- is translated as
<param name='MY.PARAM' value='MY_VALUE' /> tags.
Example
As a live example, you may have a try with the Free JDK Demo Clock applet provided by Sun here:
- Download the demo archive and extract it into your
pub/applets
- Use the markup below (on a single line) to display the clock:
(:applet codebase="demo/clock/classes"
code="JavaClock.class"
width="150" height="150":)
Life example: CalculatorApplet (adjusted by PKHG)
History
- 2007-12-05
- Solved (at last) the
$PurDirUrl issue.
- 2006-10-28
- Added RecipeInfo data.
- 2005-10-31
- Initial release.
Contributors
Dfaure
See Also
PTViewer
Comments
Clickable preview image + align left/center/right
appletimage.phpΔ is a modification of the above recipe that displays a still image (e.g. a screenshot) instead of the actual applet. Only a mouse click will turn that placeholder image into the actual applet.
Advantages
- The page loads quicker with the image instead of the applet
- A screenshot can represent the applet in the print version of the wiki page.
Requirements for this feature: JavaScript-enabled and DHTML-capable browser (tested with Firefox 3 and IE 7).
This modification adds fouroptional parameters:
clickimg="IMAGEFILE"- where IMAGEFILE is the filename of an image (gif, png, jpeg,...) to be uploaded. If this parameter is missing the recipe behaves almost (see below) like the original version of
applet.php.
clickalt="TEXT"- where TEXT is the alternative text for the preview image (:
<img alt="TEXT" src=...>)
clickcaption="TEXT"- where TEXT is a caption that goes beneath the applet or image.
clickalign="POSITION"- where POSITION is either
"left", "center", or "right" for the display of the applet/image on the page.
Beware: clickimg, clickalt, clickalign, and clickalign cannot be forwarded to the applet any more as in <param name="clickimg"...>. (The same holds for id and name, see below)
There are three optional configuration variables for config.php:
$AppletImageUploadLinkFmt- Title of an image upload link that appears beneath the running applet for as long as no image has been uploaded yet. (only when
clickimg is set, and not for ?action=print e.g.) - default: "'-Upload a preview image for this applet-'"
$AppletImageClickMeHintFmt- Text that appears beneath the still image to indicate that a mouse click will start the applet. (only when
clickimg is set, and not for ?action=print e.g.) - default: "Click on the image to start the applet."
$AppletImageDefaultAlign- Default alignment on the page if no parameter
clickalign is specified in the applet markup. The applet or the image will be aligned by using <div align="..."> - possible values here: "left", "center", "right" - default: none (default alignment in browser)
Other minor modifications in appletimage.php:
- allow for absolute URLs in the
codebase ("http://...")
- treat
id and name as properties of the <object> tag instead of forwarding them to the applet (needed for scripting applets)
I'm not that confident a programmer that I would dare to replace the original version of applet.php. But maybe others could look into merging those versions. I marked all modifications in the php source.
Enjoy! Frank.
User notes?: If you use, used or reviewed this recipe, you can
add your name. The following format is recognized:
* (+) Optional positive comment. Name, date
* (-) Optional negative comment. Name, date
These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.