• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

reference to java class

New Here ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

I'm looking to convert libreoffice java example to cfm but j don't undestand how reference to "XComponentLoader.class" before create it

this row are ok

<cfset OOB = createObject("java","com.sun.star.comp.helper.Bootstrap")/>

<cfset xContext = OOB.bootstrap()>

<cfset xMCF = xContext.getServiceManager()>

<cfset desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext)>

<cfset UnoRuntime = createObject("java","com.sun.star.uno.UnoRuntime")/>

this is then row to convert

     XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);

I try:

1)

<cfset xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>

2)

<cfset myloader = createObject("java","com.sun.star.frame.XComponentLoader")/>

<cfset xComponentLoader = UnoRuntime.queryInterface(myloader.class, desktop)>

3)

<cfobject type="Java" class="com.sun.star.frame.XComponentLoader.class" name="myloader" action="create">

<cfset xComponentLoader = UnoRuntime.queryInterface(myloader, desktop)>

but no one work

any ideas or j've to pass to cfx ?

Views

336

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , May 29, 2019 May 29, 2019

possibly

<cfset cls = CreateObject("java", "java.lang.Class")>

<cfset xCompLoaderClass = cls.forName("com.sun.star.frame.XComponentLoader")>

or

<cfset XCompLoader = CreateObject("java", "com.sun.star.frame.XComponentLoader")>

<cfset xCompLoaderClass = XCompLoader.getClass()>

then

<cfset xCompLoader = UnoRuntime.queryInterface(xCompLoaderClass, desktop)>

Votes

Translate

Translate
Community Expert ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

This is just a shot in the dark, I'm not testing this code sample. It looks like your variable names in your code examples don't match up with the ones in the Java code, though.

Java code:

XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);

CFML code:

<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader")>

<cfset xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>

You might be able to string these together using method chaining:

<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader").UnoRuntime.queryInterface(XComponentLoader.class, desktop)>

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

it still don't work, with

<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader")>

<cfset xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop)>

return the error

Element CLASS is undefined in XCOMPONENTLOADER.

and with

<cfset xCompLoader = createObject("java","com.sun.star.frame.XComponentLoader").UnoRuntime.queryInterface(XComponentLoader.class, desktop)>

return the error

Element UNORUNTIME is undefined in a Java object of type class coldfusion.runtime.StructBean. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 29, 2019 May 29, 2019

Copy link to clipboard

Copied

LATEST

possibly

<cfset cls = CreateObject("java", "java.lang.Class")>

<cfset xCompLoaderClass = cls.forName("com.sun.star.frame.XComponentLoader")>

or

<cfset XCompLoader = CreateObject("java", "com.sun.star.frame.XComponentLoader")>

<cfset xCompLoaderClass = XCompLoader.getClass()>

then

<cfset xCompLoader = UnoRuntime.queryInterface(xCompLoaderClass, desktop)>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation