Apache Pivot: Unable to render HelloBxml example

635 Views Asked by At

I'm just beginning out with Apache Pivot and started with Hello BXML example on their site. The applet just displays a grey rectangle and nothing more. I've deployed the application under tomcat with following structure: hellopivot

  • lib/pivot-*.jar
  • org.apache.pivot.tutorials.HelloBxml
  • scripts/deployJava.js
  • index.html
  • hello.bxml

index.html:

<script type="text/javascript">var attributes = {
            code : "org.apache.pivot.wtk.BrowserApplicationContext$HostApplet",
            width : "240",
            height : "80"
    };

        var libraries = [];
        libraries.push("lib/pivot-core-2.0.jar");
        libraries.push("lib/pivot-wtk-2.0.jar");
        libraries.push("lib/pivot-wtk-terra-2.0.jar");
        libraries.push("lib/pivot-web-2.0.jar");
        libraries.push("lib/pivot-web-server-2.0.jar");

        attributes.archive = libraries.join(",");

        var parameters = {
            codebase_lookup : false,
            application_class_name : 'org.apache.pivot.tutorials.HelloBxml'
        };

        var javaArguments = [ "-Dsun.awt.noerasebackground=true",
                "-Dsun.awt.erasebackgroundonresize=true" ];

        parameters.java_arguments = javaArguments.join(" ");

        deployJava.runApplet(attributes, parameters, "1.6");
</script>

hello.bxml

<Window title="Hello BXML!" maximized="true"
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns="org.apache.pivot.wtk">
    <Label text="Hello BXML!"
        styles="{font:'Arial bold 24', color:'#ff0000',
            horizontalAlignment:'center', verticalAlignment:'center'}"/>
</Window>

HelloBxml.java

@Override
    public void startup(Display display, Map<String, String> properties)
            throws Exception {
        BXMLSerializer bxmlSerializer = new BXMLSerializer();
        window = (Window)bxmlSerializer.readObject(HelloBxml.class, "hello.bxml");
        window.open(display);
    }

What am I doing wrong?

2

There are 2 best solutions below

1
Chris Bartlett On

(Disclosure - Apache Pivot PMC member)

How are you attempting to view the applet?
Which OS, JVM, browser etc are you using?

Are you able to view the hosted version of that applet using the same client configuration as the failing 'local' version? HelloBXML at offical Apache Pivot site

Do you have problems viewing any of the other Pivot applets hosted at the official site? (Demos or Tutorials?)

Issues with applets in linux environments have been reported that sound similar to your experience.

0
rwhitcomb On

Try adding the "lib/pivot-tutorials-2.0.jar" to your libraries list. That is where the 'org.apache.pivot.tutorials.HelloBxml' class file lives.