cancel
Showing results for 
Search instead for 
Did you mean: 

How can i create n display label dynamically

Former Member
0 Kudos

Hai, I want to create a label dynamically, meant when i pressed a button once one label generated for the next click of button another label. like this,

so i need to know how to create and display a label.

regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

U can create each label on action of the button click.

Foe this what u have to do is.....set a count globally.

<b>For global decalration</b>

//@@begin others

static int count=0;

//@@end

then in the wddomodifyview()

u can increase ur count by 1

wddomodifyview()

{

count++

if(firsttime)//this 4 loading label in the first time itself.

IWDLabel l = (IWDLabel)view.createElement(IWDLabel.class,"Hai");

}

The count is being is increased bcoz the wddomodify will be called on each action.

This would help u to create dynamic labels.

Regards,

Nagarajan.

Former Member
0 Kudos

Hi,

Everything is fine here.But is "count" needed here.. That too.. Not in wdDoModifyView and not at all as a static variable.

If you want to keep track of something.. globally.. create a value attribute in the context and do it.

Regards

Bharathwaj

Former Member
0 Kudos

Nagarajan,

I cannot see how your answer solves the problem.

A possible solution:

Create a context attribute <i>CreateLabel </i>of type <i>boolean</i>, set this attribute to <i>true</i> inside the action handler of the button.

In wdDoModifyView():

if ( wdContext.currentContextElement().getCreateLabel() )
{
  /* create new label with automatic ID */
  IWDLabel label = (IWDLabel) view.createElement(IWDLabel.class, null);
  /* add label to some container */
  someContainer.addChild(label);
  /* reset creation flag */
  wdContext.currentContextElement().setCreateLabel(false);
}

Armin

Former Member
0 Kudos

Hai,

I need solution for action method of a button , not in wdDomodify. please help me asap.

regards

Former Member
0 Kudos

Hi,

Armin's solution already answers your question.

Create a value attributre CreatLabel..of type boolean and set it to false in init.

Then in the button's action handler ,set it to true.

And write this code in wdDoModifyView.

In wdDoModifyView():

if ( wdContext.currentContextElement().getCreateLabel() ){  /* create new label with automatic ID */  IWDLabel label = (IWDLabel) view.createElement(IWDLabel.class, null);  /* add label to some container */  someContainer.addChild(label);  /* reset creation flag */  wdContext.currentContextElement().setCreateLabel(false);}

You should not create view element outside wdDoModifyView. So we write this in the wdDoModify view..a nd control when it is executed.. by means of setting CreateLabel value attribute..

Regards

Bharathwaj

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hai nagarajan,

Thanks for help but i need to implement it in an action(not in modify view) ,

another issue is i am using morethan 5 containers how can we specify in whch container to add the label

Former Member
0 Kudos

1. Check Armin's post and my last post.

2. To add it to a specific container..

IWDTransparentContainer tcont1 = (IWDTransparentContainer)view.getElement("ContainerID");

IWDTransparentContainer tcont2 = (IWDTransparentContainer)view.getElement("ContainerID2");

/For adding to container 1/

tcont1.addChild(label1);

/*For adding to container 2 */

tcont2.addChild(label1);

Regards

Bharathwaj

Former Member
0 Kudos

Thanks For your kind help,

Will u tell me the use of wdexit() method, when will this method invoke

Former Member
0 Kudos

Hi,

When the lifetime of view expires..

If the lifetime is framework controlled.. it's framework dependant.

If the lifetime is whenvisible .. it will be claled when the view is no longer visible.

Hope it helps.

Regards

Bharathwaj

Answers (0)