Integration Points for Silverlight
Instance Registration
// SilverlightIsland is a class provided by the WD SilverlightIsland Component
// Register the Web Dynpro wrapper's instance using this method
// at the initialization of the wrapping Silverlight application
private SilverlightIsland IslangFramework = new SilverlightIsland();
public MyPage(System.Windows.StartupEventArgs e) {
SilverlightIsland.register(myComponent);
InitializeComponent();
. . .
IslandFramework.Register(MyComponent,e); //StartupEventArgs required . . .
}
Figure 1: Register a SilverlightIsland
Method Declaration
private IIslandDatasourceList myListDataSource;
[IslandDatasource]
public IIslandDatasourceList MyListDataSource {
get {
. . .
return(myListDataSource); }
set {
myListDataSource = value;
. . .
}
}
Figure 2: Setter method declaration of a SilverlightIsland list data source
private IIslandDatasourceList myObjectDataSource;
[IslandDatasource]
public IIslandDatasourceObject MyObjectDataSource {
get {
. . .
return(myObjectDataSource); }
set {
myObjectDataSource = value;
. . .
}
}
Figure 3: Setter method declaration of a SilverlightIsland single object data source
Property Handling
// Declare as a field
[IslandDatasourceProperty]
public IIslandDatasourceProperty MyDSProperty1;
// Or alternatively declare as a setter/getter method
private IIslandDatasourceProperty myDSProperty2;
[IslandDatasourceProperty]
public IIslandDatasourceProperty MyDSProperty2 {
get {
. . .
return(myDSProperty2);
}
set {
myDSProperty = value2;
. . .
}
}
Figure 4: Handling properties being children of a data source
Properties that are not children of DataSources should be defined with the type corresponding to the backend type:
[IslandPropertyAttribute(typeof(bool))] public bool MyBooleanProperty; [IslandPropertyAttribute(typeof(string))] public string MyStringProperty; private int intProperty; [IslandPropertyAttribute(typeof(int))] public int MyIntProperty { // alternatively use getter/setter get {
. . . return(intProperty);
} set {
intProperty = value; . . .
}
}
[IslandPropertyAttribute(typeof(float))]
public float MyFloatProperty;
[IslandPropertyAttribute(typeof(double))]
public double MyDoubleProperty;
[IslandPropertyAttribute(typeof(decimal))]
public decimal MyDecimalProperty;
[IslandPropertyAttribute(typeof(DateTime))]
public DateTime MyDateProperty;
[IslandPropertyAttribute(typeof(string))]
public string MyTimeProperty;
[IslandPropertyAttribute(typeof(string))]
public string MyBinaryProperty;
Figure 5: Handling properties not being children of a data source
Wrapper Code Context Binding
public partial class MyComponent extends AnyComponent {
. . .
[IslandPropertyAttribute(typeof(string))]
public string MyTitle {
get{ return(Title); }
set{ Title = val; }
}
. . .
}
Figure 6: Web Dynpro wrapper code for context attribute binding
public partial class MyComponent extends AnyComponent {
. . .
[IslandDatasourceProperty]
public IIslandDatasourceProperty FieldX;
[IslandDatasourceProperty]
public IIslandDatasourceProperty FieldY;
[IslandDatasourceProperty]
public IIslandDatasourceProperty FieldLabel;
private IIslandDatasourceList myDataSource;
[IslandDatasource]
public IIslandDatasourceList MyDataSource {
get { return(myDataSource); }
set {
myDataSource = value;
// iterate through the data source and create the records
foreach(IIslandDatasourceObject row in myDataSource) {
AnyRecord record = new AnyRecord(); record.X = row[FieldX];
record.Y = row[FieldY];
record.Description = row[FieldLabel]; this.AddSomething(record);
}
}
Figure 7: Web Dynpro wrapper code for context node binding
Value Changes
// this function does not have to be named 'OnChangeTitle'; it represents
// a function which would be called if the title had been modified.
void OnChangeTitle(string newTitle) {
// <this> is the actual Silverlight Island which defined the property 'MyTitle'
// <'MyTitle'> is the name of the property
// <newTitle> is the new value that will be set in the context for 'MyTitle'
IslandFramework.StoreProperty(this, "MyTitle", newTitle);
}
Figure 8: Changing the value of simple control attributes (here: property title)
// this function does not have to be named 'OnRecord'; it represents
// a function which would be called if the record had been modified.
void OnChangeRecord(AnyRecord record, int recordIndex) {
IIslandDatasourceObject row = myDataSource[recordIndex];
row[FieldX] = record.X;
row[FieldY] =record.Y;
row[FieldLabel] = record.Description;
}
Figure 9: Changing the value of complex control attributes (= datasources)
Lead Selection
// this function does not have to be named 'OnLeadSelection'; it represents
// a function which would be called if the lead selection needs to be set.
void OnSelection(int recordIndex) {
// <myDataSource> is the reference to the DataSource
myDataSource.LeadSelectionIndex = recordIndex;
}
Figure 10: Changing the lead selection of a complex control attribute
// this function does not have to be named 'GetCurrentSelection'; it
// represents a function which would be called if the lead selection needs // to be retrieved.
int GetCurrentSelectionIndex() {
// <myDataSource> is the reference to the DataSource
return(myDataSource.LeadSelectionIndex);
}
Figure 11: Retrieving the node's lead selection
Firing Events
// this function does not have to be named 'HandleClick'; it
// represents a function which is triggered from user interaction
// with the control
// <'onSave'> is the name of the event
[IslandEvent("onSave")]
event IslandEventHandler SubmitSaveEvent;
void HandleClick () {
SubmitSaveEvent(this, null);
}
Figure 12: Firing a Web Dynpro event
// this function does not have to be named 'ClickHandler'; it
// represents a function which is triggered from user interaction
// with the control
// <'onSaveWithParam'> is the name of the event
[IslandEvent("onSaveWithParam")]
[IslandEventParameter(typeof(double))]
event IslandEventHandler SubmitSaveWithParamEvent;
void ClickHandler (double param) {
IslandEventArgs args = new IslandEventArgs();
args.Set("myParameter", param);
SubmitSaveWithParamEvent(this, args);
}
Figure 13: Firing a Web Dynpro event with a parameter