Hi all,
So I am currently doing my first steps in porting an existing framework to
Royale. So far I have made good progress.
I am now able to login to my SpringBoot application using Spring Security using
BlazeDS and am currently working on porting a loader application.
So as soon as a user logs in, it automatically lists the modules this user is
allowed to use and then it should load these modules.
Unfortunately something seems to be not going right with this module. While the
others worked nicely, in this case not all referenced classes are output in the
built application. Some js files are simply missing. If I manually copy them
there and add them to the dependencies in the index.html I can manage to load
them, but all in all it’s not really working.
Not sure what I’m doing wrong :-/
The code of the loader application should be quite simple and straight forward:
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<j:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:j="library://ns.apache.org/royale/jewel"
xmlns:js="library://ns.apache.org/royale/basic"
xmlns:html="library://ns.apache.org/royale/html"
xmlns:mx="library://ns.apache.org/royale/mx"
initialize="init(event)">
<j:beads>
<js:ApplicationDataBinding/>
<js:ClassAliasBead/>
</j:beads>
<fx:Declarations>
<mx:RemoteObject id="moduleService"
destination="moduleService"
fault="onError(event)">
<mx:method name="listModulesForCurrentUser"
result="onListModulesForCurrentUserResult(event)"/>
</mx:RemoteObject>
</fx:Declarations>
<fx:Style>
@namespace "http://www.w3.org/1999/xhtml";
.bgshape
{
background: #00ff00;
}
.fgshape
{
border: 1px solid #000000;
}
</fx:Style>
<fx:Script>
<![CDATA[
import de.cware.cweb.server.core.types.Enum;
import de.cware.cweb.server.module.model.FrontendModule;
import org.apache.royale.reflection.registerClassAlias;
import mx.logging.ILoggingTarget;
import mx.logging.Log;
import mx.logging.LogEventLevel;
import mx.logging.targets.TraceTarget;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.AsyncToken;
import mx.rpc.Responder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import org.apache.royale.collections.ArrayList;
import org.apache.royale.events.Event;
private var channelSet:ChannelSet;
private var enum:Enum;
private function init(event:org.apache.royale.events.Event):void {
// ArrayCollection has been renamed to ArrayList.
registerClassAlias('flex.messaging.io.ArrayCollection', ArrayList);
// Initialize the logging system
var traceLogger:ILoggingTarget = new TraceTarget();
traceLogger.filters = ["mx.rpc.*", "mx.messaging.*"];
traceLogger.level = LogEventLevel.ALL;
Log.addTarget(traceLogger);
// Get the base url of the application
var appUrl:String = getApplicationBaseUrl();
trace("Application url " + appUrl);
// TODO: For debugging ... remove
//appUrl = "http://localhost:8080";
channelSet = new ChannelSet();
// Define a short-polling-channel
var shortPollingChannel:AMFChannel = new
AMFChannel("shortPollingAmf", appUrl + "/messagebroker/short-polling-amf");
shortPollingChannel.pollingEnabled = true;
shortPollingChannel.pollingInterval = 500;
shortPollingChannel.useSmallMessages = true;
channelSet.addChannel(shortPollingChannel);
moduleService.channelSet = channelSet;
// Instantly log in as "guest"
var loginToken:AsyncToken = channelSet.login("guest",
"somepassword", "UTF-8");
loginToken.addResponder(new Responder(onLoginSuccess,
onLoginError));
}
public static function getApplicationBaseUrl():String {
var appUrl:String = window.location.href;
appUrl = appUrl.substring(0, appUrl.lastIndexOf("/"));
return appUrl;
}
private function onButtonClick(event:MouseEvent):void {
var token:AsyncToken = moduleService.listModulesForCurrentUser();
// We need to manually register until the support of defining
result hanlders
// in the mx:method element is supported …
token.addResponder(new Responder(onListModulesForCurrentUserResult,
onError));
}
private function onLoginSuccess(event:Event):void {
trace("Login Success");
// After successfully logging in, we have to load the list of
modules
// the user is allowed to use.
var token:AsyncToken = moduleService.listModulesForCurrentUser();
// We need to manually register until the support of defining
result hanlders
// in the mx:method element is supported …
token.addResponder(new Responder(onListModulesForCurrentUserResult,
onError));
}
private function onLoginError(event:Event):void {
trace("Login Error " + event);
}
private function
onListModulesForCurrentUserResult(event:ResultEvent):void {
trace("Got Module List:");
var moduleList:ArrayList = ArrayList(event.result);
for each(var frontendModule:FrontendModule in moduleList) {
trace(" " + frontendModule.name);
}
}
private function onError(event:FaultEvent):void {
trace("Fault");
}
]]>
</fx:Script>
<j:initialView>
<j:View width="100%" height="100%">
<j:beads>
<j:HorizontalCenteredLayout/>
<j:Paddings padding="50"/>
</j:beads>
<j:Card width="460" height="680">
<j:CardHeader>
<html:H3 text="Conferences" className="primary-normal"/>
</j:CardHeader>
<j:CardPrimaryContent>
<!--j:List width="100%" height="100%"
dataProvider="{conferences}"
change="onConferenceSelectionChange(event)"
labelField="name"/-->
<j:Button width="100%" text="Get Module List"
click="onButtonClick(event)">
<!--j:beads>
<j:Disabled disabled="{selectedConference ==
null}"/>
</j:beads-->
</j:Button>
</j:CardPrimaryContent>
</j:Card>
</j:View>
</j:initialView>
</j:Application>
The pom also should be quite simple:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.cware.cweb</groupId>
<artifactId>cweb-frontend</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>cweb-frontend-application</artifactId>
<packaging>swf</packaging>
<name>C-Web: Frontend: Application</name>
<build>
<sourceDirectory>src/main/royale</sourceDirectory>
<plugins>
<!--
This plugin doesn't actually do anything in the build,
it only makes IntelliJ turn on Flex support
-->
<plugin>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>7.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.royale.compiler</groupId>
<artifactId>royale-maven-plugin</artifactId>
<version>${royale.version}</version>
<extensions>true</extensions>
<configuration>
<mainClass>App.mxml</mainClass>
<targets>JSRoyale</targets>
<debug>true</debug>
<additionalCompilerOptions>-source-map=true;</additionalCompilerOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.royale.compiler</groupId>
<artifactId>compiler-jx</artifactId>
<version>${royale.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>de.cware.cweb</groupId>
<artifactId>cweb-core-frontend-utils</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>de.cware.cweb</groupId>
<artifactId>cweb-module-frontend-utils</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>Core</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>Jewel</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>Language</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>Network</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>Reflection</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>MXRoyale</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<classifier>js</classifier>
</dependency>
<!-- Use the Jewel Theme -->
<dependency>
<groupId>org.apache.royale.framework</groupId>
<artifactId>JewelTheme</artifactId>
<version>${royale.version}</version>
<type>swc</type>
<scope>theme</scope>
<classifier>js</classifier>
</dependency>
</dependencies>
</project>
Anyone can spot something bad happening here?
Chris