cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic programming

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

the group has gridlayout and colcount 2.

i want to set the colsapn of the textview i add to the group as 2. how can i do this?

thanks

Former Member
0 Kudos

Hi,

There is a property called colSpan .set it to 2.

If u r talking about dynamic programming I dont think it is possible with GridLayout... It is usually available with GridBagLayout only..

Message was edited by: Bharathwaj R

Former Member
0 Kudos
{
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);
}
Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

You are stting values to the variables textView and linkToUrl first as yahoo and more. Later though initialize different variables, you are using the same textView and linkToUrl to set the values rediff and more.

Kindly use textView1 and linkToUrl1 instead during the second time.