Dynamic View Services > Specifying Dynamic View Types > View Parameters > Displaying a View in a Given Window
 
Displaying a View in a Given Window
As another example of the use of view parameters, suppose you want the view DepartmentTable to be always displayed in an existing window. The identifier of this window can be a parameter of the view type, assigned to the window attribute of a user-defined representation type named TableRepresentation:
view DepartmentTable(int wId=0):
represent TableRepresentation:
int windowId=wId;
....
The wId parameter is directly accessible without any path because the representation is associated with the view type itself. This parameter can be set by the component when opening a view DepartmentTable (see the functions IlsMvComponent::openView and IlsRpObject::openView in the Rogue Wave® Server Reference Manual for details) or when dereferencing a hyper-reference on this type of view.
In the code sample below, the linkName attribute of a Department object in the CompanyTree view is a hyper-reference to the DepartmentTable view:
view CompanyTree:
...
subscribe Department:
represent TreeItem item:
...
HyperRef linkName={DepartmentTable,name};
The callback function TreeItem::onSelection executed on selection of the tree item might set the address of the window to be used by the new TableRepresentation:
void TreeItem::onSelection(){
IlsMvValue parameters[1];
parameters[0]=TableRepresentation::GetWindowId();
onDereference(getAttributeId("linkName"), parameters,1);
}
Note that you must close the current representation before dereferencing the hyper-reference if you want only one representation in your window:
void TreeItem::onSelection(){
   TableRepresentation* lastRepres;
   lastRepres=TableRepresentation::GetCurrentRepresentation();
   IlsMvValue parameters[1];
 
if (lastRepres){
lastRepres->close();
}
...
}

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.