Calling inner class of a Java Class in Railo

Thanks to the Railo documentation on Github, I finally found the answer I was searching for...

Question: how to call an inner Java class of a Java class with Railo?

Answer: use a $ sign: createObject("java", "$innerClass")

Long version:

I was busy implementing the javaEWSApi (MS Exchange Web Services API) into a new mobile project, but got stuck on getting the unread-count for the user’s Inbox. An example online said to use the following Java code:

// Get five items from mail box
ItemView view = new ItemView(5);
//Set Filter to Read UnRead emails
SearchFilter itemFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, true);
// Search Inbox
FindItemsResults<item> findResults = service.findItems(WellKnownFolderName.Inbox,itemFilter,view);
// iterate thru items
for (Item item : findResults.getItems()) {

All fine and good it seemed. Just change “new ItemView” and “new SearchFilter” to createObject("java", "...") calls, and I would be good to go. Alas, there was a problem.
This is the cfscript code I first created:

public Numeric function getUnreadCount()
    local.exchangeService = getExchangeServiceForCurrentUser();

    // Get an item from mail box
    local.itemView = createObject("java", "#variables.msClassPath#ItemView").init(1);

    //Set Filter to Read UnRead emails
    local.msgSchema = createObject("java", "#variables.msClassPath#EmailMessageSchema");
local.itemFilter = createObject("java", "").IsEqualTo(local.msgSchema.IsRead, false);

    // Search Inbox
    local.inbox = createObject("java", "#variables.msClassPath#WellKnownFolderName").Inbox;
    local.findResults = local.exchangeService.findItems(local.inbox, local.itemFilter, local.itemView);
    return local.findResults.getTotal()

The code threw an error on the highlighted line, with error: “No matching Method for IsEqualTo(, boolean) found for

After quite some googling and trying different constructs, I checked the java source code, and saw the following:
 * copyright file="" company="Microsoft"
 *     Copyright (c) Microsoft Corporation.  All rights reserved.
 * Defines the
public abstract class SearchFilter extends ComplexProperty {
    public static class IsEqualTo extends RelationalFilter {
        public IsEqualTo(PropertyDefinitionBase propertyDefinition,
                Object value) {
            super(propertyDefinition, value);

What was new to me, was the class definition “IsEqualTo” within the class SearchFilter.
But it was a great starting point for a new web search, and led me to

because Occur is an Inner Class of BooleanClause, you will need to reference it via the $ delimiter [...], so the full path for the Occur inner class is$Occur
<cfset objBooleanClauseOccur        = createObject( "java", "$Occur" )>

Awesome! Lesson learned. Thanks to the Railo team, for creating this invaluable documentation page :-D Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 3987 times

No comments yet.

(will not be published)
Leave this field empty