cancel
Showing results for 
Search instead for 
Did you mean: 

how to create dynamic elements in action of a view?

Former Member
0 Kudos

hi all,

I created 2 buttons dynamically in WdDoModifyView(). I created action1, and parameter for that action i.e, id of type string.

when i click on button1, some ui elements must be displayed.....

can anyone tell me how to dynamically add UI elements in onAction() of view.....

i wrote the following code to create & map dynamically in WdDoModifyView()........

if(firstTime)

{

IWDButton b1=(IWDButton)view.createElement(IWDButton.class,"button1");

b1.setText("Button1");

IWDButton b2=(IWDButton)view.createElement(IWDButton.class,"button2");

b2.setText("Button2");

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

tc.addChild(b1);

tc.addChild(b2);

IWDButton butt1 = (IWDButton)view.getElement("button1");

IWDParameterMapping pm1a = butt1.mappingOfOnAction();

pm1a.addParameter("id1","link1a");

IWDButton butt2 = (IWDButton)view.getElement("button2");

IWDParameterMapping pm1b = butt2.mappingOfOnAction();

pm1b.addParameter("id1","link1b");

}

after writing this..... in onAction().........of view... i wrote like this...

if (id1.equals("link1a"))

{

}

else{

}

in the if & else condition, i have to create UI elements dynamically.

when i am trying to create Ui elements dynamically, but i am unable to create dynamically here.

pls give me suggestion how to proceed this

regards,

vila

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Static because the flag variable is to be referenced in wdDoModifyView()

Avinash

Former Member
0 Kudos

Not static, because this will not work Use context attribute instead.

Armin

Former Member
0 Kudos

Hi

As mentioned above, the UI elements can be created only in the wdDoModifyView.

But what you can do is to disable them first and on Action method set a flag variable as TRUE,

The UI Elements can be enabled for the true values of this flag variable. Also the flag variable should be a static variable.

Thanks and Regards

Avinash

Former Member
0 Kudos

No, not static.

Armin

Former Member
0 Kudos

Hi Vila,

Are you trying to create UI elements dynamically in the action? If yes then you won't be able to do so because you can only create UI elements dynamically in WDDoModifyView().

Always WDDoModifyView() would be called after your action. So, you can handle it as you want in your WDDoModifyView() itself.

But if you want that those elements should be created everytime when you fire an event then don't write it within if(firstTime) clause as this would be true only when WDDoModifyView() is called for the first time when the page intially loads.

Regards,

Murtuza