cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete WD component usage?

former_member186148
Active Participant
0 Kudos

Hello SDN.

We have a WDJ application consists of two WD components: one component is the list of business objects (ListComp) and the second one is the screen with object's attributes (ScreenComp). The application separated to two components since ScreenComp has to be reusable. ListComp used ScreenComp with "onDemand" flag. ScreenComp has a lot of fields and table fields with OVS. For OVS we have developed separate WD comp (GenericSH) and some Java classes which help us to cofigure OVSes. GenericSH is used in ScreenComp with flag "manual". OVSes configured in Component controller of ScreenComp.

OVSes configured and created with usage.createComponentUsageOfSameType() while ScreenView is called. OVSes deleted with usage.deleteComponent() when user leaves ScreenView.

But if user leaves ScreenView and then calls this view again the following error occured:


Cannot create object with the name workKind and rolenameComponentUsages because it already exists.

(workKind is the name of the OVS usage)

So how we can properly delete component usage and then create it again?

We're working with NW 7.31

Regards,

Lev

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

i think you should use createComponent

former_member186148
Active Participant
0 Kudos

Hello Jun.

I tried to use createComponent in this way:


unitUsage = wdThis.wdGetGenericSHComponentUsage();

unitUsage.createComponent();

IExternalGenericSHInterface intrfcUM = (IExternalGenericSHInterface)unitUsage.getInterfaceController()

     .wdCastTo(IExternalGenericSHInterface.class);

IWDOVSContextNotificationListener listenerUM = intrfcUM.getListener(unitOVS);

WDValueServices.addOVSExtension(IPrivateIndexView.IIndexRecordElement.UNIT_MEASURE_TXT_SHORT,

     new IWDAttributeInfo[]{nodeIndInfo.getAttribute(IPrivateIndexView.IIndexRecordElement.UNIT_MEASURE_TXT_SHORT)},

     intrfcUM.getInputNode(),

     intrfcUM.getOutputNode(),

     listenerUM);

IWDComponentUsage phdWrkKndUsage = wdThis.wdGetGenericSHComponentUsage();

phdWrkKndUsage.createComponent();

IExternalGenericSHInterface intrfc = (IExternalGenericSHInterface)phdWrkKndUsage.getInterfaceController()

     .wdCastTo(IExternalGenericSHInterface.class);

IWDOVSContextNotificationListener listener = intrfc.getListener(myOVSListener);

WDValueServices.addOVSExtension(IPrivateIndexView.IWorkKindsElement.WORK_KIND,

     new IWDAttributeInfo[]{phdWrkKndInfo.getAttribute(IPrivateIndexView.IWorkKindsElement.WORK_KIND)},

     intrfc.getInputNode(),

     intrfc.getOutputNode(),

     listener);

This method called everytime when ScreenView is called.

On the exit from ScreenView I try to delete usage:


if(phdWrkKndUsage != null){

     phdWrkKndUsage.deleteComponent();

}

if(unitUsage != null){

unitUsage.deleteComponent();

}

(phdWorkKndUsage and unitUsage  are attributes of the ScreenView Comp Controller).

When I try to call ScreenView I'm faced with this exception:

ComponentUsage(com.acme.view.indexes.wd.comp.indexview.IndexView:GenericSH, createOnDemand=false, childComponent=com.acme.wd.searches.comps.genericsh.GenericSH): No active component must exist when creating a component.

This exception throwed at the line with phdWrkKndUsage.createComponent();

Thanks and regards

Lev

Message was edited by: Lev Kulaev Found an error in the previous version of the message.

junwu
Active Contributor
0 Kudos

check if your exit method get called or not.

former_member186148
Active Participant
0 Kudos

Exception throwed before any exit method called.

Let me give more details about it.

If I try to use createComponent() as mentioned in my previous message I get an exception


ComponentUsage(com.acme.view.indexes.wd.comp.indexview.IndexView:GenericSH, createOnDemand=false, childComponent=com.acme.wd.searches.comps.genericsh.GenericSH): No active component must exist when creating a component.

during the first call of ScreenView on the line phdWrkKndUsage.createComponent(); => the first OVS initials correctly and the second one throws exception.

Also please note that I try to use the same used WD Component for two OVSes since it is common WD OVS Component.

Regards,

Lev

junwu
Active Contributor
0 Kudos

at design time, create two usage

or when creation , check if active component exits or not, if exits, delete and create

former_member186148
Active Participant
0 Kudos

I thought about this. But the problem is there not two OVSes, two were for example. In fact there are 20 fixed OVSes and some OVSes for dynamically generated fields. I'm just curious what problems with createComponentUsageOfSameType(). Is it limits of WD framework to delete such usages or I miss something. Is it good way to create usage with this method and name+current timestamp (just to be sure it will be unique)?