cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of UI Element on the action of a button?

Former Member
0 Kudos

Hi,

Can we create some UI Element on the action of some button, i.e. writing code to create UI Element outside the wdDoModifyView() method of the view?

Regards,

Smriti.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi All,

Check this thread,

It gives you information on why we should not create static view reference, or even have a context attribute for view reference.

Can anyone explain, why we should not try either of the cases?

Thanks and Regards,

Prabhakar.

Former Member
0 Kudos

Yes ...You certainly create a button ..in WdDoModifyView();

You have to import IWDAbstactButton or WDAbstactButton..check api..

first locate root container and use above method a button..it will enable during runtime..

Regards

Ravi

Former Member
0 Kudos

Hi,

create a context variable of type boolean name it "buutonAction"

write below code

in the Action of Button

OnActionClickButton{

wdContext.currentContextElement.setButtonAction(true);

}

write this code in wdDoModifyview(){

IWDLinkToAction actionDivision=(IWDLinkToAction)view.createtElement(IWDLinkToAction.class,null);

actionDivision.setText("generated link");

actionDivision.setReference("http://www.google.com");

}

Regards,

Naga

Former Member
0 Kudos

Hi,

We can create an UI element dynamically, on button click action..Follow the steps given below:

1. Create a static variable say ' myvar ' of type com.sap.tc.webdynpro.progmodel.api.IWDView in last declaration part(ie. inside //@@begin others //@@end.

Eg: static IWDView myview;

2. 2. In wdDoModifyView(), add the following

myview=view;

3. Now add the following code in the "OnAction<Submit>" event to create an UI element dynamically:

IWDTransparentContainer rootContainer = (IWDTransparentContainer)view.getElement("RootUIElementContainer");

IWDLinkToAction Link1 = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "Link1");

rootContainer.addChild(Link1);

Hope it helps!!!

Regards,

TFG - Kumara Guru

Former Member
0 Kudos

Hi,

Change 'view' in step 3, to 'myview'.

regards,

Prabhakar.

Former Member
0 Kudos

Hi,

Yes, update it as "myview" in step 3 (the static variable name should be used)..

I haven;t noticed that...thanks

Regards,

TFG - Kumara Guru

Former Member
0 Kudos

Thanks to every one for great help. I have resolved the issue.

Former Member
0 Kudos

NO!

Search the forum to find why you shall never use a static reference to the view.

Armin

Former Member
0 Kudos

Hi,

i dont think you can do that, but certainly you can make the visibility of a UI element visible or invisible on click of a button and i think this can solve your problem.

Regards

TFG - Anirban

former_member182372
Active Contributor
0 Kudos

Smriti, you can set the flag using context attribute and depending on flag value perform UI modification in wdDoModifyView.