on 04-08-2008 5:21 AM
Hi all,
I need to create labels dynamically in my view. The text for these labels should be set from data accessed from a sql table. My sql table contains two fields 'id' and 'name'.
Currently my sql database table has 5 records.I am able to print all these in the wdmodify view.
But how can I create the label for these 5 records and set its text with 'name' from the sql table?
for eg: label1.setText(<set with 'name' from database table>)
How will I do this dynamically?code would be helpfull
Thanks
in WDModifyView() {
if(firstTime) {
IWDTransparentContainer container = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDLabel label;
//recordset is your database return
for(int i = 0; i<recordset.length;i++){
label = (IWDLabel)view.createElement(IWDLabel.class,new String("label"+i));
container.addChild(label);
label.setText(recordset.getID());// get ID from recordset
}
nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try this code
//@@begin wdDoModifyView
IWDTransparentContainer container = (IWDTransparentContainer)view.getElement( "RootUIElementContainer");
IWDLabel label;
for( int i = 0; i < 10; i++)
{
container.addChild( label = (IWDLabel)view.createElement( IWDLabel.class, "Label_" + i));
label.setText( "Label " + i);
}
//@@end
to display the database value say id to the label, you can directly set the contextElement that you bind with the database field to the setText(). You can convert the type of it by using .toString() or Typecast to string Ex:
label.setText( (String)wdContext.currentContextElement().getID());
or
label.setText( wdContext.currentContextElement().getID().toString());
Regards
- Vinod
*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
write the following code in the wdDoModifyView() method.
1)First get the Ref of the Transaparent container.
IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("id of container");
IWDLabel label=(IWDLabel)view.createElement(IWDLabel.class,null);
label.setText("Text1");
con.addChild(label);
Regards
Hazrath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.