main.mxml
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" preinitialize="Ejb.getInstance().initApplication()" creationComplete="init();" layout="absolute">
<mx:Text id="teksti" text="Foobar123"></mx:Text>
<mx:Script>
<![CDATA[
import org.granite.tide.ejb.Ejb;
import org.granite.tide.ejb.Context;
import org.granite.tide.ejb.Identity;
import org.granite.tide.events.TideUIEvent;
import org.granite.tide.service.DefaultServiceInitializer;
import org.granite.tide.data.events.TideDataConflictsEvent;
import org.granite.tide.data.Conflicts;
import mx.events.CloseEvent;
import org.granite.tide.events.TideResultEvent;
import org.granite.tide.events.TideFaultEvent;
import mx.controls.Label;
import mx.controls.Text;
import fi.insomnia.bortal.beans.EventBean;
import mx.controls.Alert;
//Ejb.getInstance().addComponentWithFactory("serviceInitializer", DefaultServiceInitializer,
// { contextRoot: "/graniteds-tide-ejb3" });
// Ejb.getInstance().addModule(AddressBookModule);
private var tideContext:Context = Ejb.getInstance().getEjbContext();
private var text1:Label;
private function init():void {
identity.isLoggedIn();
text1 = new Label();
text1.x = 50;
text1.y = 80;
text1.text = "Flashparam 3 Map: "+ parameters.param1 ;//+ " Username: " + identity.username + " LoggedIn: " + identity.isLoggedIn();
this.addChild(text1);
tideContext.flashMapBean.getMapBackground(1,1, eventhandler,helloFault);
// Ejb.getInstance().getEjbContext().addEventListener(TideDataConflictsEvent.DATA_CONFLICTS, conflictsHandler);
}
private function eventhandler(event:TideResultEvent):void {
var text2:Label = new Label();
text2.x = 50;
text2.y = 100;
text2.text = "Got result3!!";
this.addChild(text2);
var text3:Label = new Label();
text3.x = 50;
text3.y = 150;
Alert.show(event.result.toString());
var txt3:String = "null";
if(event.result != null)
{
txt3 = event.result.name;
}
text3.text = txt3;
this.addChild(text3);
}
private function helloFault(event:TideFaultEvent):void {
var text2:Text = new Text();
text2.x = 50;
text2.y = 100;
text2.text = event.fault.toString();
this.addChild(text2);
}
private var _conflicts:Conflicts;
private function conflictsHandler(event:TideDataConflictsEvent):void {
_conflicts = event.conflicts;
Alert.show("Someone else has modified the person you are currently working on.\nDo you want to keep your modifications ?",
"Modification conflict", Alert.YES | Alert.NO, null, conflictsCloseHandler);
}
private function conflictsCloseHandler(event:CloseEvent):void {
if (event.detail == Alert.YES)
_conflicts.acceptAllClient();
else
_conflicts.acceptAllServer();
}
[Bindable] [In]
public var identity:Identity;
]]>
</mx:Script>
</mx:Application>