on 02-10-2006 7:53 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.