When you work with the Dexterra framework, you don’t really have access to any of the notification engines you normally would have on the front end of an application. This became a major problem for us in a project we were working on.
Our goal was that we had a details screen for data with a button that would take you to a form with a list of selectable items. When an item was selected from the list, we wanted to show the selection in our details screen without having to send the data back into the dexterra business objects from the list screen, and then read the updated data from the database into the detail screen.
We were using Dexterra version 5.6.1 for our development and the solution we found was this.
We have two forms DetailsScreen and ListScreen inheriting from the Dexterra.Framework.Screen class.
Inside the ListScreen we have an public event named ListItemSelectedEvent and on the DetailsScreen we have a button named btnListSelection.
I am not going to show how the ListItemSelectedEvent gets triggered in this example,if needed i can post an update with the code.
First of all we need to create an ActionLaunch object. We solved this in our application with an FlowHander class.
FlowHandler flow = new FlowHandler();
We have a number of methods in this class. Returning the most common Action objects we use from the Dexterra framework, ActionLaunch, ActionDone, ActionExit, ActionBack. The one we need is ActionLaunch and we get it from the method GoToNewScreen:
public ActionLaunch GoToNewScreen(Component parentComponent,
String target)
{
ActionLaunch actionLaunch = new ActionLaunch();
actionLaunch.EventHandlerTypeName = "actionLaunch";
actionLaunch.FriendlyName = "actionLaunch";
actionLaunch.InitiatorEvent = "Click";
actionLaunch.ParentComponent = parentComponent;
// CreatePocketPCSheet returns a configured
// PocketPCSheet object
// Not included
actionLaunch.Target =
CreatePocketPCSheet(target);
ActionFlow actionFlow = new ActionFlow();
actionFlow.Actions.Add(actionItem);
actionFlow.EventHandlerTypeName = "";
actionFlow.FiringPattern = FiringPattern.None;
actionFlow.FriendlyName = "actionFlow";
actionFlow.InitiatorClass = null;
actionFlow.InitiatorEvent = null;
return actionLaunch;
}
In our DetailsScreen class we have a member variable for the ActionLaunch and our ListScreen;
private ActionLaunch _newScreenLaunch; private ListScreen _listScreen;
In the Load method of DetailsScreen we create the ActionLaunch and subscribe to our button click event.
private void Form_Load(object sender, System.EventArgs e)
{
btnListSelection.Click += btnListSelectionEvent;
string newScreen = "projectname.ListScreen";
_newScreenLaunch = flow.GoToNewScreen(this,newScreen);
}
DetailsScreen is the parent component (this) and newScreen is the full path to the screen to open. Dexterra will use reflection to add this to it’s stack.
Finally we have the event method for our button click where we perform the _newScreenLaunch action and get the ListScreen from the screen stack.
private void BtnChangeStationClick(object sender, EventArgs e)
{
_newScreenLaunch.PerformAction();
Host host =
EngineCache.Instance[EngineCache.DEFAULT]
.ScreenStack.Peek();
if (IsTargetMyListScreen(host.TargetInstance)
{
_listScreen = (ListScreen) host.TargetInstance;
_listScreen.ListItemSelectedEvent +=
UpdateDetailsFormWithSelection;
}
}
We perform the action – this puts our ListScreen on the top of the screen stack and trigger Dexterra action for opening the screen.We then retrieve it from our screen stack. Validate that it is a ListScreen we got before we subscribe to the event.
private bool IsTargetMyListScreen(Dexterra.Framework.Screen target)
{
if (target == null) return false;
if (target is ListScreen) return true;
else return false;
}
and then subscribe to the event on the ListScreen.
_listScreen = (ListScreen) host.TargetInstance;
_listScreen.ListItemSelectedEvent +=
UpdateDetailsFormWithSelection;
When the ListItemSelectedEvent event fires – the UpdateDetailsFormWithSelection method is triggered and we update our DetailsScreen data.
I am still quite new to Dexterra but have not found any easier way to come around this, we also got pointers from Dexterra Central that this was the best way to do it.
What must be said here is that our application was created from code and code only, we did not use any of the WYSIWYG (What You See Is What You Get) Dexterra encourages you to use, since we found that building applications in drag and drop just doesn’t give you usable applications in any commercial form.
We created the application with a MVP (Model-View-Presenter) application pattern and used Dexterra as an integration and data access platform in this app.
This post doesn’t render well on mobile devices. Sorry about that