Object | +--global
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |
| Properties Summary | |
app |
app
This object is automatically instantiated as the app property of the global object (or global.app) and there is no constructor to instantiate further instances. |
File |
File
Constructor for File objects, providing read and write access to the file system. |
FtpClient |
FtpClient
Constructor for File objects, to send and receive files from an FTP server. |
HopObject |
HopObject
Constructor for HopObject objects, providing the building blocks of the Helma framework. |
Image |
Image
Helma's built-in image object allows you to read, manipulate, and save images. |
Mail |
Mail
Helma's built-in mail client enables you to send e-mail via SMTP. |
PathWrapper |
path
Accessing objects in the URI path. |
XmlRpcObject |
Remote
Constructor for Remote objects, implementing an XML-RPC client. |
req |
req
This object is automatically instantiated as the req property of the global object (or global.req) and there is no constructor to instantiate further instances. |
res |
res
This object is automatically instantiated as the res property of the global object (or global.res) and there is no constructor to instantiate further instances. |
HopObject |
root
Represents the root of the object model hierarchy. |
session |
session
This object is automatically instantiated as the session property of the global object (or global.session). |
HopObject |
User
The built-in User prototype. |
Xml |
Xml
The Xml object provides easy means to convert XML to HopObject and HopObjects to XML. |
<static> Object |
helma
Library object for the HelmaLib javascript library. |
| Methods Summary | |
Boolean
|
authenticate(<String> username,<String> password)
Authenticates a user against a standard Unix password file. |
Skin
|
createSkin(<String> skin)
Creates a Skin object from the passed String. |
void
|
defineLibraryScope(<String> namespace)
Declares a custom global namespace that will not be garbage collected. |
Object
|
deserialize(<String> filename)
Deserialize a JavaScript object that was previously serialized to a file. |
String
|
encode(<String> text)
Encodes a string for HTML output and inserts linebreak tags. |
String
|
encodeForm(<String> text)
Encodes a string for HTML output, leaving linebreaks untouched. |
String
|
encodeXml(<String> text)
Encodes a string for XML output. |
String
|
format(<String> text)
Encodes a string for HTML output, leaving existing markup tags untouched. |
String
|
formatParagraphs(<String> text)
Encodes a string for HTML output, inserting paragraph tags. |
DatabaseObject
|
getDBConnection(<String> datasource)
Connects to a relational database, and returns a DatabaseObject representing that connection. |
HTMLDocumentImpl
|
getHtmlDocument(<String> source)
Parses an HTML string to an XML DOM tree. |
String
|
getProperty(<String> property,<String> defaultvalue)
Looks up a property that was set in app.properties or server.properties Returns any property defined in [AppDir]/app.properties, resp. |
MimePart
|
getURL(<String> url,<String> etagOrDate)
Retrieves a file/document from the passed URL as a MimePart Object, and therefore functions as a minimalist version of a HttpClient. |
XmlDocument
|
getXmlDocument(<String> source)
Parses an XML string to an XML DOM tree. |
void
|
onCodeUpdate()
If defined, the onCodeUpdate() function is called whenever the code is recompiled. |
void
|
onLogout()
If defined, the onLogout() function is called when a user is logged out. |
void
|
onRequest()
If defined, the onRequest() function is called before each page request is handled. |
void
|
onResponse()
If defined, the onResponse() function is called after each page request is handled but before the response is returned. |
void
|
onStart()
If defined, the onStart() function is called when the application is started. |
void
|
onStop()
If defined, the onStop() function is called when the application is stopped. |
void
|
renderSkin(<String> skin,<Object> params)
Renders the passed SkinObject or a global skin matching the passed name to the response buffer. |
String
|
renderSkinAsString(<String> skin,<Object> params)
Returns the result of the rendered SkinObject or a rendered global skin matching the passed name. |
void
|
seal(<Object> obj)
Seals an object, and prevents any further modifications of that object. |
void
|
serialize(<Object> obj,<String> filename)
Serialize a JavaScript object to a file. |
String
|
stripTags(<String> markup)
Removes any markup tags contained in the passed string, and returns the modified string. |
Object
|
toJava(<Object> obj)
Converts a Javascript String, Date, etc to its Java counterpart. |
Map
|
unwrapJavaMap(<Object> obj)
Unwrap a map previously wrapped using wrapJavaMap(). |
Object
|
wrapJavaMap(<Packages.java.util.Map> obj)
Wrap a java.util.Map so that it looks and behaves like a native JS object. |
void
|
write(<String> text)
Writes a string to java.lang.System.out, i.e. |
void
|
writeln(<String> text)
Writes a string together with a line break to java.lang.System.out, i.e. |
<static> void
|
now_macro(param)
renders the current datetime |
<static> void
|
property_macro(param)
write out a property contained in app.properties |
<static> void
|
skin_macro(param)
renders a global skin |
<static> void
|
write_macro(param)
wrapper to output a string from within a skin just to be able to use different encodings |
| Properties Detail |
app app
File File
var fileOrDir = new File('static/test.txt');
FtpClient FtpClient
var ftp = new FtpClient("ftp.mydomain.com");
HopObject HopObject
Image Image
var img = new Image("http://helma.org/image.gif");
Mail Mail
PathWrapper path
for (var i=0; i < path.length; i++) res.writeln(path[i]); HopObject file HopObject document HopObject story HopObject note var obj = path.story; res.write(obj); HopObject storyThe path object behaves similar to a Javascript array, but it is actually an instance of the Packages.helma.scripting.rhino.PathWrapper Java class.
XmlRpcObject Remote
var xr = new Remote("http://helma.domain.tld:5056/");
var msg1 = xr.helmaorg.getXmlRpcMessage();
if (msg1.error)
res.write(msg1.error);
else
res.write(msg1.result);
Hello, Xml-Rpc World!
var msg2 = xr.hotelGuide.hotels.grandimperial.getXmlRpcMessage();
if (!msg2.error)
res.write(msg2.result);
Welcome to the Grand Imperial Hotel, Vienna!
var msg3 = xr.kolin.document.comments["23"].getXmlRpcMessage();
if (!msg3.error)
res.write(msg3.result);
Here you can write your comments.
var xr = new Remote("http://betty.userland.com/RPC2");
var state = xr.examples.getStateName(23);
if (!state.error)
res.write(state.result);
Minnesota
req req
For further details also see the JavaDocs for Packages.helma.framework.RequestBean. Since that class is a JavaBean all of its get- and set-methods are also directly available as properties of this object.
res res
HopObject root
session session
HopObject User
Xml Xml
<static> Object helma
app.addRepository("modules/helma/Search.js");
See:
| Method Detail |
Boolean authenticate(<String> username,<String> password)
var login = authenticate("user", "pass");
if (login)
res.write("Welcome back!");
else
res.write("Oops, please try again...");
Welcome back!
username - as String
password - as String
Skin createSkin(<String> skin)
var str = "Hello, <% response.body %>!"; var skin = createSkin(str); res.data.body = "World"; renderSkin(skin); Hello, World!
skin - as String
void defineLibraryScope(<String> namespace)
namespace - as String, the name of the protected namespace
Object deserialize(<String> filename)
filename - as String, the file to deserialize the object from
String encode(<String> text)
var str = encode("<b>Bananer växer\n minsann inte på träd.<b>");
res.write(str);
<b>Bananer växer
<br /> <br> minsann inte på träd.</b>
text - as String
String encodeForm(<String> text)
var str = encodeForm("<b>Bananer växer\n minsann inte på träd.</b>");
res.write(str);
<b>Bananer växer
minsann inte på träd.</b>
text - as String
String encodeXml(<String> text)
var str = encodeXml("<title>Smørebrød</title>");
res.write(str);
<title>Smørebr&oslash:d</title>
text - as String
String format(<String> text)
var str = format("<b>Bananer växer\n minsann inte på träd.</b>");
res.write(str);
<b>Bananer växer
<br /> minsann inte på träd.</b>
text - as String
String formatParagraphs(<String> text)
var str = format("Smørebrød:\n\n<b>Bananer växer\n minsann inte på träd.</b>");
res.write(str);
<p>Smørebrød:</p>
<p><b>Bananer växer
<br /> minsann inte på träd.</b></p>
text - as String
DatabaseObject getDBConnection(<String> datasource)
var dbConnection = getDBConnection("db_source_name");
var dbRowset = dbConnection.executeRetrieval("select title from dummy");
while (dbRowset.next())
res.writeln(dbRowset.getColumnItem("title"));
var deletedRows = dbConnection.executeCommand("delete from foobar");
if(deletedRows){
res.writeln(deletedRows + " rows successfully deleted");
}
datasource - name as String
HTMLDocumentImpl getHtmlDocument(<String> source)
See the JavaDocs for that class for further details.
FIXME: Links to other recommended HTML parserssource - as String, HTML formatted
String getProperty(<String> property,<String> defaultvalue)
property - as String, the name of the property to look up
defaultvalue - as String, optional default/fallback value
MimePart getURL(<String> url,<String> etagOrDate)
url - as String
etagOrDate - either the etag as String or a Date object
XmlDocument getXmlDocument(<String> source)
See the JavaDocs for that class for further details.
FIXME: Link to JavaDocs and other recommended XML parserssource - as String, using XML syntax
void onCodeUpdate()
void onLogout()
void onRequest()
void onResponse()
void onStart()
void onStop()
void renderSkin(<String> skin,<Object> params)
skin - as SkinObject or the name of the skin as String
params - as Object, optional properties to be passed to the skin
String renderSkinAsString(<String> skin,<Object> params)
skin - as SkinObject or the name of the skin as String
params - as Object, optional properties to be passed to the skin
void seal(<Object> obj)
obj - that is to be sealed
void serialize(<Object> obj,<String> filename)
obj - as Object, the object to be serialized
filename - as String, the file to serialize the object to
String stripTags(<String> markup)
markup - as String, the text that is to be stripped of tags
Object toJava(<Object> obj)
obj - as String, Date, Boolean, Number, etc.
Map unwrapJavaMap(<Object> obj)
obj - as Object, a map previously wrapped using wrapJavaMap()
Object wrapJavaMap(<Packages.java.util.Map> obj)
obj - as Packages.java.util.Map to be wrapped
void write(<String> text)
text - as String, the message that is to be output
void writeln(<String> text)
text - as String, the message that is to be output
<static> void now_macro(param)
Object - containing a formatting string as format property
<static> void property_macro(param)
Object - containing the name of the property
<static> void skin_macro(param)
<static> void write_macro(param)
Object - containing the string as text property
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |