cancel
Showing results for 
Search instead for 
Did you mean: 

Replicating the same set of UI thru wdDoModifyView()

Former Member
0 Kudos

Hi All,

I have a requirement to replicate a set of UI elements already present in the view with different dat i.e.,

i have a transparent container which has some UI elements. i have populated some data in to it. But now i have to display another transparent container(same as mentioned above) with some different data....DINAMICALLY...

Thanks in advance

Srikanth Emani

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Thanks a lot everybody....

May b i didn't get the required answer(i mean even SAP might not have a solution) but most of the problem is solved....

And thanks for every body for helping me

Srikanth Emani

Former Member
0 Kudos

What does that mean "even SAP might not have a solution"? I have proposed three different ways to tackle your problem. Which one didn't work for your requirement?

Armin

Former Member
0 Kudos

Your solutions are gud and I said even sap doesnt have a solution just because i mean that we dont have a direct method to copy and replicate the same set with different data.......

Like we have a copy service method for model nodes........similarly i thought if there is any method or something.....Ofcourse i know we cannot compare nodes with UI but i thought if there is something like that i would have been much more pleased with my requirement ......

Regards,

Srikanth

Former Member
0 Kudos

I still do not understand your requirement. Do you have an existing view that is created by code and you want to have a way of duplicating this at runtime or what is it?

Armin

Former Member
0 Kudos

Hi Armin,

First of all i have created a set of Ui by draging and dropping(i mean NOT from CODE ). Now i have to replicate the same set of UI one below the other dynamically(i mean THRU CODE), since i dont know how many records are there in my DB which i will be binding to the UI.

I had a solution from one of the previous replies, but if there is any better solution you know , can share with us.

If u still dont understand the requirement please feel free to ask me again.NP

Srikanth

Former Member
0 Kudos

To implement a UI that depends on the number of records you can use elements like Table, RowRepeater etc. that are filled from context node elements.

To use a complete view at different places, put it inside a reusable component and create different component usages wherever you need them.

Armin

Former Member
0 Kudos

One option is to create a component that represents the UI to be used repeatedly. Then you can create different component instances and embed them into the parent view using ViewContainerUIElements.

Another option is to put the code that creates the repeated UI into a method that is called for different parent containers. Here you have to take care to get the data-binding correct.

Or maybe you can use a RowRepeater UI element.

Armin

Former Member
0 Kudos

Hi Expert,

Firstly you have to declare reference of UI element In WdmodifyView()

public static void wdDoModifyView(IPrivateCompView wdThis, IPrivateCompView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

if(firstTime){

// rootup---id of parent transparentcontainer

IWDTransparentContainer trT=(IWDTransparentContainer)view.getElement("rootup");

IWDTransparentContainer tr=(IWDTransparentContainer)view.createElementIWDTransparentContainer.class,"firstcontainer");

IWDGridLayout layf=(IWDGridLayout)tr.createLayout(IWDGridLayout.class);

layf.setColCount(2)

IWDTextView vie=(IWDTextView)view.getElement("Id of Lable ");

vie.setText("First name");

tr.addChild(vie);

.....

,......

......

trT.addChild(tr);

IWDTransparentContainer trsec=(IWDTransparentContainer)view.createElementIWDTransparentContainer.class,"secondcontainer");

IWDGridLayout lays=(IWDGridLayout)tr.createLayout(IWDGridLayout.class);

lays.setColCount(2);

IWDTextView viesec=(IWDTextView)view.getElement("Id of Lable ");

viesec.setText("First name");

trsec.addChild(vie);

;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;

trT.addChild(trsec);

}

}

Hope its work fine...

thanks

Sudhira

Former Member
0 Kudos

Hi Anagha & Pravesh,

i think u did not clearly understood my problem....

I know we can copy paste the UI elements but this becomes a static way of replicating the UI. Instead i want to generate the same set of UI thru code i.e., from wdDoModifyView() method(which I have mention in the Subject line ).

My main aim is to replicate the UI from the code but not populating the data..

Hope u understood my problem.

please revert back if u need any more clarity....

Thanks,

Srikanth Emani

pravesh_verma
Active Contributor
0 Kudos

Hi Srikanth ,

Sorry we misunderstood your question. Creating the elements dynamically in wdDoModify() function is not easy if you dont know what elements are there in the initial root container. However I have tried to write one code for doing this, may be this helps you:


IWDTransparentContainer transContainer = (IWDTransparentContainer)view.getElement("RootContainer");
	  
	  IWDUIElement[] uiElements = transContainer.getChildren();
	  int noOfEle = uiElements.length;
	  
	  for (int i = 0; i < noOfEle; i++) {
		  IWDUIElement element = uiElements<i>;

		  String type = element.getClass().getName();

		  if(type.equalsIgnoreCase(IWDLabel.class.getName())){
			  IWDLabel label = (IWDLabel)view.createElement(IWDLabel.class, "Copied_Label" +element.getId());	
		  }
		  if(type.equalsIgnoreCase(IWDTextView.class.getName())){
			  IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, "Copied_Label" +element.getId());	
		  }

		  if(type.equalsIgnoreCase(IWDInputField.class.getName())){
			  IWDInputField inputField = (IWDInputField)view.createElement(IWDInputField.class, "Copied_Label" +element.getId());	
		  }
// SO ON....... 
// You should know what type of UI elements are  there in your previous container..
	  }

Please note that:

1) The root container should have ID named: RootContainer.

2) You should know type of UI elements in your earlier container

I hope this solves you issue. There is no other way in which you can achieve this kind of very generic requirement. Please close the thread if you have got your answer or kindly revert back for kind of further issues.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Pravesh,

Thank you very much for the idea you have given. We can do it that way but there will be a problem if we

have nested transparent containers. But as u said we need to know the UI elements we have and code

will b a bit long. Ofcourse we can handle that thru code but i just wanna know if there is something, like a Copy service for model nodes, so that we can just copy the outer transparent container and assign with a new label?

Thanks you once agian for giving a solution for my problem..

Srikanth Emani

former_member185086
Active Contributor
0 Kudos

Hi

One question :Whether , your requirement can fill is this way that A view having some UI filled with data, on particular action ,same set of UI will come with different set of data will display.

another point is Does it require to display above requirement in same view or in any popup window .

What I want to discuss is we can use the same view again and again only thing which require is data(a little efforts)

Let us know ....

Best Regards

Satish Kumar

pravesh_verma
Active Contributor
0 Kudos

Hi Srikanth,

First of all good that you atleast have some solution of your problem.. However regarding some API for directly copying the UI elements is not there. This is really a kind of very strange requirement and believe me I have seen this for the first time

Anyways, I would like to clear one of your doubt.. As you said:

We can do it that way but there will be a problem if we have nested transparent containers.

There will be no probelm even if there are nested transparent container. You just need to add 1 line of if set for all the transaparent containers. It will not make the code very lengthy. It's in the same way in which I have mentioned above.

See the most important thing you have to note down in my above answer is : YOU SHOULD KNOW THE TYPE OF ALL DIFFRENT UI ELEMENTS IN YOUR ROOT CONTAINER.

Please note the bold words.. Different Ui elements.. This mean if in the root container there are 5 Lables, 6 input fields, 4 Transparent container, 7 Text fields and so on... Then you should know that there are: Labels,Input fields, Transparent Conatiner, TextField. that's all. And the n you have to write 4 if statements in the way I have written above..

You need not have to write 5 if statements for labels, 6 for input fields, 4 for Transparent cobtainer and so on.. The code is written in such way that it will identify the all the childrens of the root container and then it will create all the UI elements in the for loop irrespective of their numbers.

So please dont worry about the no of UI elements , just worry about the Type of UI elements !!

I hope this clarifies your issue.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Hi Srikanth,

I think you should probably go for Reflection + BeanUtils.. Would be a cleaner, cost effective and general solution for your problem.

However, can you please specific describe your requirement?

Maybe you're missing something. Building the UI in wdModifyView is expensive and, it will happen at each Round-Trip... I'm quite sure you shouldn't need that, so you can probably isolate this behavior in some other method.

I'd just ask you to be more specific, what's exactly your problem?

Regards,

Daniel

pravesh_verma
Active Contributor
0 Kudos

Hi Srikanth,

Just copy and paste the first transparent container. Create a copy of the node which you have in the context. Please note that you have to copy only those nodes which are bonded to the transparent container number 1.

Do that binding of the new container with this new set of nodes and attributes. At run time you can set the values of this newly copied node which is now binded to the new container.

I hope this helps! This is very basic idea if you want to ask more details please let me know.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Srikanth,

You have a set of UI which might be displaying some data or accepting some data from end user. These UI elements are in a transparent container, you wish to have the same set of UI with different data to be displayed on some action.. am I correct.

First at design time, just right click your 1st transparent container and select "copy" option.

Paste the same as child in the Root UI element container. Now this copy is your 2nd transparent container.

Now if you want this 2nd UI should appear dynamically on a button click or something, in init method set its visible property as WDVisibility.NONE. In the OnAction() method of that button Change the visible property of this UI as WDVisibility.VISIBLE. Also set the required data into the UI elements in this method.

Regards,

Anagha