cancel
Showing results for 
Search instead for 
Did you mean: 

get the existing tab by name at runtime

konchada_saikrishna
Active Participant
0 Kudos

Hi all,

I need to get weather a tab exist by this name or not .. my scenario is

I will have a properties file with a list of field properties along with information to which tab this field belong ...?

At runtime I need to create a tabstrip...

Then i need to get 1st field's tabname, check weather a tab exist with this name or not..

if it exist create & add this field to that tab and context, else create new tab and then add.

add the tab to the tab strip. so on to all fields

finally tab strip to the rootcontainer

He ineed how to get a tab by name,

how to create a value attribute under a value node for the view context..

Thanks in advance .

Sai.k.k

Accepted Solutions (0)

Answers (2)

Answers (2)

konchada_saikrishna
Active Participant
0 Kudos

Thanks Armin, for all your help.

I could solve it,

Former Member
0 Kudos
wdDoModifyView()
{
   IWDViewElement e = view.getElement("TabID");
   if (e instanceof IWDTab)
   {
     /* There exists a tab named "TabID" */
   }  
}

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Armin,

I am using below code

IPrivateview1.IparentElement ele= wdContext.parentElement();

wdContext.nodeparent().addElement(ele);

IWDAttributeInfo attrinfo=wdContext.getChildNode("parent",0).getNodeInfo().addAttribute(resourceHandler.getString("FIELD"i"_FIELDNAME"),"ddic:com.sap.dictionary."resourceHandler.getString("FIELD"i+"_DATATYPE"));

I am getting an error :

com.sap.dictionary.runtime.DdException: Dictionary Type com.sap.dictionary.String does notExist

Here in addAttribute(string,string)

I used "string" & "ddic:com.sap.dictionary.string" too still getting the same error

Can you tell me what might be the error, how to resolve this.

Regards,

Sai.k.k

Former Member
0 Kudos

"ddic:com.sap.dictionary.string" should work.

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Armin,

yes it is working, It was "String" in the properties file and hence the error.

Finally regarding the Tab,

I could create New tab, add labels and textboxs to it, but may be due to that it was in flowlayout, I could not see any of them but just a text box.

I am using gridlayout like the below, but getting an classcastexception

IWDTransparentContainer tcont = (IWDTransparentContainer)view.getElement(resourceHandler.getString("FIELD"i"_TAB"));

IWDGridLayout layout =(IWDGridLayout)tcont.createLayout(IWDGridLayout.class);

layout.setColCount(3);

Thanks,

Sai.k.k

Former Member
0 Kudos

Is the ID of the tab content container really

resourceHandler.getString("FIELD"+i+"_TAB")

?

Or is that the ID of the tab itself? That would explain a ClassCastException.

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Armin,

Have a look at this code

<pre>

for(int i=1;i<=fieldscount;i++)

{

IWDAttributeInfo child = parent.addAttribute(resourceHandler.getString("FIELD"i"_FIELDNAME"),"com.sap.dictionary."resourceHandler.getString("FIELD"i+"_DATATYPE"));

IWDInputField field = (IWDInputField) view.createElement(IWDInputField.class,"Field_"+i);

field.bindValue(child);

IWDLabel label = (IWDLabel)view.createElement(IWDLabel.class,"Label_"+i);

label.setText(resourceHandler.getString("FIELD"i"_LABEL"));

label.setLabelFor("Field_"+i);

IWDViewElement Ele = view.getElement(resourceHandler.getString("FIELD"i"_TAB"));

if(Ele instanceof IWDTab)

{

IWDTab existtab = (IWDTab)view.getElement(resourceHandler.getString("FIELD"i"_TAB"));

existtab.setContent(label);

existtab.setContent(field);

}

else

{

<b>IWDTab tab1 = (IWDTab)view.createElement(IWDTab.class,resourceHandler.getString("FIELD"i"_TAB"));</b>

IWDCaption header1 = (IWDCaption) view.createElement(IWDCaption.class,resourceHandler.getString("FIELD"i"_FIELDNAME"));

header1.setText(resourceHandler.getString("FIELD"i"_TAB"));

tab1.setHeader(header1);

IWDTransparentContainer tcont = (IWDTransparentContainer)view.getElement(resourceHandler.getString("FIELD"i"_TAB"));

IWDGridLayout layout =(IWDGridLayout)tcont.createLayout(IWDGridLayout.class);

layout.setColCount(3);

tab1.setContent(label);

tab1.setContent(field);

ts.addTab(tab1);

// count++;

}

}

theActionContainer.addChild(ts);

</pre>

Former Member
0 Kudos

There is still a bug in your code:

You cannot add elements inside a tab by calling tab.setContent() several times. You have to add the elements to a container C and then set this container as the content for the tab using

tab.setContent(C);

Armin

konchada_saikrishna
Active Participant
0 Kudos

Yes,

but I changed that ....

I need to set maxlength to the textboxs, can you tell me how to create simple types dynamically and assign them to the same..

Thanks & Regards,

Sai.k.k

Former Member
0 Kudos

Please open a new thread.

Armin