cancel
Showing results for 
Search instead for 
Did you mean: 

Fireing outbound plug of interface view from within component

Former Member
0 Kudos

Hi all,

is there a better way of firing an outbound plug of an wd component interface view than from within the interface view controller itself?

The problem is, that you easly get a cyclic reference if you evaluate inbound component plugs in the interface controller (usage from int view ctrl --> int ctrl needed) and then try to fire an outbound plug from this interface controller (usage comp int --> comp int view usage needed).

One workaround is to use some custom controller with usage of the interface view, but this doesn't seem to be a nice solution.

So is it possible to fire outbound comp plugs from, lets say the component controller - without any usage releation to the comp int view - instead, maybe via wdComponentAPI? If yes, could you provide a code snippet?

Thanks you and best regards,

Christian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christian,

this is not possible by using the public API only, i'm afraid. It is of course possible, if you decide to forget about the possible drawbacks of using methods and classes reserved for internal use. But you have to use it at your own risk. I hacked this together some weeks ago, don't know whether it still works

/**
 * Fires an outbound plug of an interface view with parameters.
 * 
 * @param wdComponentAPI Component API "owning" the interface view.
 * @param windowName Name of window
 * @param plugName Name of outbound plug
 * @param callerParameterMap optional Map of plug parameters.
 */
public static final void fireOutboundPlug(
  IWDComponent wdComponentAPI,
  String windowName,
  String plugName,
  Map callerParameterMap)
  throws WDRuntimeException {

  // Find window requested
  IWDWindowInfo windowInfo = wdComponentAPI.getComponent().getComponentInfo().findInWindows(windowName);
  if (windowInfo == null) {
    throw new WDRuntimeException(
      "Can't find window: " + windowName + " in component: " + wdComponentAPI.getQualifiedName());
  }
  // Get info of interface view
  IWDInterfaceViewInfo ifViewInfo = windowInfo.getInterfaceView();
  if (ifViewInfo == null) {
    throw new WDRuntimeException("Window: " + windowName + ", no interface view info found");
  }
  // Find outbound plug 
  IWDOutboundPlugInfo outboundPlug = ifViewInfo.findInOutboundPlugs(plugName);
  if (outboundPlug == null) {
    throw new WDRuntimeException(
      "The interface view: " + ifViewInfo.getName() + " has no outbound plug: " + plugName);
  }
  // Parameter passing
  Collection plugParameters = outboundPlug.getParameters();
  // TODO make check optional, check caller map parameter keys against existing
  if (plugParameters == null || plugParameters.isEmpty()) {
    // No caller parameters allowed.
    if (callerParameterMap != null && !callerParameterMap.isEmpty()) {
      throw new WDRuntimeException(
        "The outbound plug: " + plugName + " has no parameters, callerParams must be empty/null.");
    }
  }
  // TODO This is a hack, use of internal WD runtime classes and methods (don't use productive).
  InterfaceView ifViewController =
    (InterfaceView) ((Component) wdComponentAPI.getComponent()).getController(ifViewInfo.getName());
  ifViewController.navigate(outboundPlug.getName(), callerParameterMap);
}

Please remember, that not everything which is technically possible, makes sense

Regards

Stefan

Former Member
0 Kudos

hi guys,

I am having problems with a cyclic component usage also. It seems I cannot navigate between interface views in the same Component controller, without creating a cycle.

What is the best design for multiple interface views/windows in one component? (ie. i want to navigate from one "viewset" to another).

thanks,

michael

Former Member
0 Kudos

Hi Michael,

the solution working for is. Using the int ctrl in the int view for handling inbound plugs. Vice versa, using a custom controller which uses the int view for firing outbound plugs. That seems for now to be the only working solution without cyclic refernces.

Best regards,

Christian

Answers (0)