cancel
Showing results for 
Search instead for 
Did you mean: 

Make copies of an object dynamically by Code ?

diegohs
Active Participant
0 Kudos

Hi everyone,

After all... thanks for your help, believe that I found more valuable help here than in marketplace. 😃

THE question of this time is: I have a group created in design time, then I need to make several copies of it in runtime (with code).

How can I make these copies ? I found the object WDCopyService but I can't make an instance of the class =(

Any valuable help with this ?

Regards from Mexico 😃

Diego

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

As Bertram point this out you took wrong direction.

What you need is to traverse recursively UI elements from cloning target (inclusive), going into recursion on any that implements IWDUIElementContainer and apply a bit of Java Reflection on every step to copy property values / bindings.

VS

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Diego,

the WDCopyService class is only used for copying node elements form one context (model or value) node to another based on equal attribute names and compatible attribute types.

But, as I assume, this is not the right copy service for your requirement. You probably want to copy UI-element subtrees starting from an existing root UI-element, e.g. a Group. For this scenario Armin can give you an answer.

Greetings, Bertram

Former Member
0 Kudos

<i>How can I make these copies ? I found the object WDCopyService but I can't make an instance of the class =(</i>

Because it is so-called Booch Utility Class -- class sole purpose of which is to provide static utility methods. so what you can is call directly WDCopyService.copyCorresponding(...) or other methods

<BR/>

VS

Former Member
0 Kudos

What exactly do you want to copy? How does your use case look like?

Armin

diegohs
Active Participant
0 Kudos

Hi Everyone,

Thanks for your help... I have a couple of days with this problem, and after that I decided to solve it with a different approach.

Now I have another error trying to fill the ToolBarDropDownByKey object dynamically.. but that's another log... 😃

Thanks and regards,

Diego

Former Member
0 Kudos

Why don't you write what the problem was and how you solved it? Other readers might have the same problem and look for a solution too.

Armin

diegohs
Active Participant
0 Kudos

Well, my problem was not solved at all. But at least, I dont need to "clone" objects.

At first, I was trying to create a TabStrip dynamically, and clone its contents in each tab. Tabs are identically except for 1 parameter.

But, now I'm trying to display just 1 container with a ToolBarDropDownByIndex object, and when the user change the value in the combo box, I need to refresh the screen.

Now, I'm having problems doing the 2nd. option.. =(

Thanks for your help and regards,

Diego

Former Member
0 Kudos

I see 2 possibilities:

1. Create a Web Dynpro component for those UI parts that have the same structure. Embed instances of this component in views using IWDViewContainerUIElement placeholders.

or

2. Implement a method which creates the UI tree for similar parts, and provide method parameters to create the variants. Call this method at appropriate times in wdDoModifyView() to initialize/modify the view structure.

Cloning of UI trees created at design time is not trivial, so I would not suggest to do this.

Armin