Opening Views
There are multiple ways to open a dynamic view either from the server or from a component:
using the server API;
using the component API;
using command line options;
using the connection panel.
Whatever the technique you choose, you must first select the server object that will be the main origin of the view.
Selecting the Main Origin
There are also several techniques to designate the server object that will be the main origin of the view. It can be designated by:
a pointer to this server object;
a representation object associated with that server object;
a hyper-reference attribute owned by a representation object;
a label that has been previously associated with that object in the server, as shown here:
int main(int argc, char** argv)
{
if (!IlsMvServer::Initialize(argc,argv)){
...
}
...
Company* myCompany= // build a company
IlsMvServer::DeclObjectLabel(*myCompany,"MyCompanyName");
...
}
Note: A server object can be associated with one label only. Conversely, a label can designate only one server object. If the label is the value of a data member of the object, it is your responsibility to undeclare the old association and redeclare the new one when the data member is modified. When the server object is deleted, the association is implicitly removed by the server. |
In the following section, we will use the following extract of the specification of the view CompanyTree:
view companyTree (int a_param,string another_param):
represent TreeGadgetRepresentation:...
subscribe origin Company:...
subscribe Department:
represent TreeItemR item:
HyperRef linkName={this->DepartmentTable,name};
Opening a View from the Server API
On the server side, you can open the CompanyTree view of the object myCompany by calling the following function:
IlsMvServer::OpenView(myCompany,"CompanyTree");
Similarly, this view can be opened by passing the label of the object as an argument:
IlsMvServer::OpenView("MyCompanyName","CompanyTree");
In both cases, the new view will be associated with a default linked component that is implicitly created by Rogue Wave® Server. If you want the view to be opened for a specific component, you must pass the address of its interface as the third parameter to the OpenView functions.
Example
IlsMvComponentItf* compItf=...;
IlsMvServer::OpenView("MyCompanyName","CompanyTree",compItf);
If necessary, you can specify the initial value of the view parameters:
IlsMvValue args[2];
args[1]=1959;
args[2]="This is a string";
IlsMvServer::OpenView("MyCompanyName","CompanyTree",compItf,args,2);
By default, Rogue Wave Server does not re-open a view that is already open. However, you can force the opening, like this:
IlsMvServer::OpenView("MyCompanyName","CompanyTree",compItf,args,2,IlsTrue);
If you want to know the status of a view opening, you can pass a status address as the last parameter to the OpenView functions. Its value will be automatically assigned by Rogue Wave Server:
IlsOpenViewStatus openViewStat;
IlsMvServer::OpenView("MyCompanyName","CompanyTree",compItf,args,2,
IlsTrue,&openViewStatus);
switch (openViewStatus){
case ILS_OPEN_OK=...;
case ILS_ALREADY_OPENED=...;
case ILS_OPEN_ILLEGAL_ORIGIN=...;
case ILS_OPEN_REFUSED=...;
case ILS_OPEN_FAILED=...;
case ILS_OPEN_UNKNOWN_VIEWTYPE=...;
}
See the enumerated type IlsOpenViewStatusE in the Reference Manual for a description of the status values.
Opening a View from the Component API
On the component side, there are several ways to open a view:
You can write a request to the server, like this:
IlsMvComponent* comp=...;
comp->openView("MyCompanyName","CompanyTree");
You can also request the opening of a view from a representation object. Assuming that the representation object
treeItem is associated with a
Department object in the server, you can open the view
DeparmentTable on the
Department object, like this:
TreeItemR& treeItem=...;
treeItem.openView("DepartmentTable");
Another way of opening a view consists in dereferencing a hyper-reference:
TreeItemR& treeItem=...;
int linkNameAttrId=treeItem.getAttributeId("linkName");
treeItem.onDereference(linkNameAttrId);
As for the previous functions IlsMvServer::OpenView, you can pass view parameter values as arguments to these functions, as well as the Boolean status to force the opening:
IlsMvValue args[2];
args[1]=1959;
args[2]="This is a string";
treeItem.openView("DepartmentTable",args,2,IlsTrue);
Unlike what happens when you choose to use the server API, opening a view from the component is a complete asynchronous process which is handled by the general interaction cycle mechanism (detailed in
Interaction Cycles). However, it is sometimes necessary to be informed of the result of this action. Moreover, you may need to define a specific local context to be used in addition to the specified view parameters. This is the case, for instance, when the view representation is created. In that case, Rogue Wave Server provides additional asynchronous functions,
openView and
onDereference, with the following extra parameters:
an array of values;
the size of this array;
the position in the array where Rogue Wave Server must place the result of the view opening.
When the transaction that requests the opening of the view is acknowledged or rolled back, the virtual function ackOpenView is executed on the component with the array of values (including the result of the opening) and the array size passed as parameters. So all you have to do is override the ackOpenView function if you need to execute a special piece of code when a view opening request is acknowledged or rolled back.
Moreover, after the representation has been created in the component—if the opening of the view was successful—and before any representation objects are created, the virtual function IlsRepresentation::onCreation is executed on this representation with the array and its size as parameters. Just override this function when you need a specific initialization of a representation.
Opening Views Using Command Line Options
The same view can also be opened by passing additional arguments on the command line of the component (or of the linked server), as follows:
mycomponent -ilsc myserver@serverHost
-ilsv MyCompanyName.CompanyTree
Of course, you must first declare an object MyCompanyName on the server side and load the CompanyTree view type specification file to this server.
Opening Views from the Connection Panel
When developing a graphical application using Rogue Wave Views, you can use the connection panel supplied in the Rogue Wave Server library mvconpan to:
get the list of the server object labels registered with the server;
get the list of dynamic view types that can be opened on a selected server object;
open a view on that object.
Refer to
Connection through the Connection Panel to learn how to initialize the connection panel.
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.