Rogue Wave Server/Rogue Wave Views Integration > Server/Views Mapping > Opening Views in the Server/Views Mapping > Opening a View
 
Opening a View
To open a view within the Server/Views mapping, use one of the following methods:
*IlsSwComponent::openSwView
*IlsSwTable::openSwView
*IlsSwTable::propertySwOnDereference
*IlsSwRow::swOnDereference
*IlsSwRow::openSwView
Note: Dereferencing a hyper-reference is the same action as opening a view.
Warning: You cannot call any member function of the base classes IlsMvComponent or IlsRpObject to open a view because those functions do not manage reserved view parameters correctly and do not look for a preregistered Server data source.
However, if you have to call the API of a base class to open an Server/Views view, you can overcome this drawback by using the static member function IlsSwComponent::PrepareViewParameters. This function prepares an array of view parameters (including your own parameters, if needed) that must be called before opening the view using methods of the standard Rogue Wave Server API such as IlsMvComponent::openView or IlsRpObject::onDereference.
Here is a code sample that can be used typically to open a view using an existing Server data source:
IlsSwComponent* component = (IlsSwComponent*)IlsSwComponent::Connect(serverName, hostName);
if (!component) {
IlsError() << "Failed to connect to server" << IlsEOM;
return 1;
}
 
// instantiate a panel
IlvRect bbox;
bbox.moveResize(25, 40, 500, 500);
MyPanel* cont = new MyPanel(display, "MyPanel", "MyPanel", &bbox, IlvFalse, IlvTrue, 0, 0);
 
 
// Retrieve the Server data source
IlsSwServerDataSource* sds = cont->getSDS();
if (sds) {
// opening the view on TheNetwork
component>openSwView("TheNetwork",
"MyView",(IlsSwServerDataSource*)sds));
}
 
 
// run the graphical Mainloop
IlvMainLoop();
 
return 0;
}
In this example, the component that is created when a connection is opened is an instance of the class IlsSwComponent. A panel is created with a Server data source. The view is opened based on the IlsSwComponent API and on the Server data source used as a view parameter.
OpenView Context
When opening a view, you can pass a context that will be notified when the representation is created or that will be passed in the IlsMvComponent::ackOpenView member function if the opening of the view fails.
In the Server/Views mapping, this context is used to trigger a callback when the view has been opened on the component side or when the component is notified that the opening of the view has failed.
This context is provided in the ackArgv, ackArgc and resIndex parameters of the openSwView member functions and of any other function that opens a view. The Server/Views mapping expects the status of the openView function at the first index of the ackArgv array. The resIndex parameter is set to 0. An internal index is sent to the second position of the ackArgv array.
The context is managed internally by the openSwView and SwDereference functions. The member function IlsSwComponent::PrepareViewParameters also manage this context along with your own context if you provide one.
When using the Server/Views mapping, index 0 and index 1 of the OpenView context (ackArgv) are reserved.
OpenView Callback
When opening a view in the Server/Views mapping, you can specify a callback that will be called in the following situations:
*when the whole representation model is created if the view is opened correctly;
*If the view has already been opened on the same server object and if the force mode is set to IlsFalse, the callback is called from the ackOpenView method.
*If the view has not been opened, the callback is called from the ackOpenView method.
*If the view has been opened, the callback is called at the end of the first notification cycle for this view. It means that all IlsSwTable or IlsSwRow representation objects have been created and that the Views data sources have been filled.
See the basic type IlsSwOpenViewCallbackType in the Reference Manual for more information.
Whenever this callback is called, you can consider that the view is open and you can begin to update the Views data source to interact with the server.
Here is a typical code extract showing how to install this callback:
static void _OpenViewCb(IlsSwRepresentation* repres,
const IlsString& viewName,
IlsOpenViewStatus status,
IlsAny arg)
{
// this callback is called when the view has been opened on the
// component side
}
 
...
// opening the view on TheNetwork
component>openSwView("TheNetwork",
"MyView",(IlsSwServerDataSource*)sds,
0,0,IlsFalse,OpenViewCallback,cont));
...
Using the Connection Panel
Within the Server/Views mapping, opening a view from the connection panel calls the virtual function IlsSwComponent::openingViewFromConnectionPanel. This function is called by a OpenView callback set on the connection panel. By default, it calls an openSwView method without any parameters. You may override this function if you want to control the way views are opened.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.