on 06-27-2005 11:42 AM
hi,
i am doing dynamic creation of textview and LinkToURL UI elements.
there is a group in the view in which i want to display some text and next to that a link to URL with text 'more' to know more about the text displayed through textview.
this is the code that i have written in wdDoModifyView method of the view
if(firstTime)
{
IWDTransparentContainer rootContainer = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDGroup group = (IWDGroup)view.getElement("link_Group");
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class,"textView1");
textView.setText("Yahoo...");
IWDLinkToURL linkToURL = (IWDLinkToURL)view.createElement(IWDLinkToURL.class,"link1");
linkToURL.setText("more");
linkToURL.setReference("http://www.yahoo.com");
rootContainer.addChild(textView);
rootContainer.addChild(linkToURL);
IWDTextView textView1 = (IWDTextView)view.createElement(IWDTextView.class,"textView2");
textView.setText("Rediff...");
IWDLinkToURL linkToURL1 = (IWDLinkToURL)view.createElement(IWDLinkToURL.class,"link2");
linkToURL.setText("more");
linkToURL.setReference("http://www.rediff.com");
rootContainer.addChild(textView1);
rootContainer.addChild(linkToURL1);
}
when i run this code only the second textview ('Rediff') and linkToURL('http://www.rediff.com') are displayed.
The first textview('Yahoo') and linkToURL('http://www.yahoo.com') that i add to group are not displayed.
can anybody plz.. tell me why and what i can do to get them.
Just a matter of style:
When writing such code, I use blocks to group statements that later will make it into a separate method.
As Valery correctly remarked, use NULL for view element IDs you don't need.
In your example I would write
{
IWDTextView textView = (IWDTextView)
view.createElement(IWDTextView.class, null);
textView.setText("Yahoo...");
IWDLinkToURL linkToURL = (IWDLinkToURL)
view.createElement(IWDLinkToURL.class, null);
linkToURL.setText("more");
linkToURL.setReference("http://www.yahoo.com");
group.addChild(textView);
group.addChild(linkToURL);
}
{
// same code, same local variable names for second group...
}
This avoids mistakes like the one you did.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
{
IWDTextView textView = (IWDTextView)
view.createElement(IWDTextView.class, null);
textView.setText("Yahoo...");
<b>IWDGridData gridData = (IWDGridData)
textView.createLayoutData(IWDGridData.class);
gridData.setColSpan(2);</b>
IWDLinkToURL linkToURL = (IWDLinkToURL)
view.createElement(IWDLinkToURL.class, null);
linkToURL.setText("more");
linkToURL.setReference("http://www.yahoo.com");
group.addChild(textView);
group.addChild(linkToURL);
}
1. First, you are adding links / texts to RootUIElementContainer rather then to group.
2. You do not add group itself to RootUIElementContainer.
3. [just side-note] Avoid using identifiers for UI controlls when they are unnecessary -- simply pass null as second argument to view.createElement
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the following
if(firstTime)
{
IWDTransparentContainer rootContainer = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDGroup group = (IWDGroup)view.getElement("link_Group");
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class,"textView1");
textView.setText("Yahoo...");
IWDLinkToURL linkToURL = (IWDLinkToURL)view.createElement(IWDLinkToURL.class,"link1");
linkToURL.setText("more");
linkToURL.setReference("http://www.yahoo.com");
rootContainer.addChild(textView);
rootContainer.addChild(linkToURL);
IWDTextView textView1 = (IWDTextView)view.createElement(IWDTextView.class,"textView2");
textView1.setText("Rediff...");
IWDLinkToURL linkToURL1 = (IWDLinkToURL)view.createElement(IWDLinkToURL.class,"link2");
linkToURL1.setText("more");
linkToURL1.setReference("http://www.rediff.com");
rootContainer.addChild(textView1);
rootContainer.addChild(linkToURL1);
}
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.