cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Dynamic UI Generation

Former Member
0 Kudos

Hi

I created 2 views

I fired an RFC on the click of a button on first view.

The output of RFC is the set of records generated depending on the input.

First screen is used as selection screen to select data which will act input for RFC

I

need to print the records in the second view . For this<b> i created

textviews dynamically depending on the no of rows retrieved</b>.

Now if the user clicks "Back" button from second view and selects different input values. I need to recreate the textviews again with new no of records retrieved.

Since more than 1 UI element cannot be created with the same id, again creating the UI elements is giving error.

I cannot use destroyAllChildren() method before recreating since there are lots of other UI elements and destroyAllChildren() will destroy all .

Please help.

Suitable Reward Points will be given if anyone solves the problem.

Regards

Sonal Mangla

Accepted Solutions (1)

Accepted Solutions (1)

roberto_tagliento
Active Contributor
0 Kudos

You have a specic place where to work dynamically.

IWDUIElementContainer container = (IWDUIElementContainer)

view.getElement("ID_CONTAINER_YOUR_DYNAMIC_POINT");

container.destroyAllChildren();

and after do all your ADD

container.addChild(text);

Former Member
0 Kudos

Thanks for the prompt reply but i have already mentioned that I cannot use destroy AllChildren() because there are lots of other UI elements too which are not generated dynamically and which i cannot afford to destroy and recreate dynamically.

roberto_tagliento
Active Contributor
0 Kudos

Found a way to regenerate also old dynamic UI element, use WorkAREA context NODE.

roberto_tagliento
Active Contributor
0 Kudos

Here i create a Table

//@@begin javadoc:CreateTable()

/** Declared method. */

//@@end

public void CreateTable( com.sap.tc.webdynpro.progmodel.api.IWDView view, com.sap.tc.webdynpro.progmodel.api.IWDUIElementContainer container )

{

//@@begin CreateTable()

String BindTextBase = new String("__Sie__Swe_Cs_Bapi_Wd_Equipment_Input.Output_Search_Equi.It_Equnr.");

String BindTextName = new String("");

String TextHeader = new String("");

IWDTable tb = (IWDTable) view.createElement(IWDTable.class, null);

tb.bindDataSource("__Sie__Swe_Cs_Bapi_Wd_Equipment_Input.Output_Search_Equi.It_Equnr");

tb.setVisibleRowCount(16);

IWDAction theAction = wdThis.wdCreateAction(IPrivateElencoApperecchi.WDActionEventHandler.VISUALIZZA_DETTAGLIO,"Visualizza Dettaglio.");

tb.setOnLeadSelect(theAction);

IWDTableColumn tbc = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);

IWDTextView text = (IWDTextView) view.createElement(IWDTextView.class, null);

BindTextName = BindTextBase + "Equipment";

text.bindText(BindTextName);

IWDCaption header = (IWDCaption) view.createElement(IWDCaption.class, null);

header.setText("Equipment");

tbc.setHeader(header);

tbc.setTableCellEditor(text);

tb.addColumn(tbc);

wdContext.nodeColumnSelezionati().moveFirst();

do {

tbc = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);

text = (IWDTextView) view.createElement(IWDTextView.class, null);

TextHeader = wdContext.currentColumnSelezionatiElement().getText();

TextHeader = TextHeader.substring(0, TextHeader.lastIndexOf("("));

header = (IWDCaption) view.createElement(IWDCaption.class, null);

header.setText(TextHeader);

tbc.setHeader(header);

BindTextName = BindTextBase + wdContext.currentColumnSelezionatiElement().getNameCol();

text.bindText(BindTextName);

tbc.setTableCellEditor(text);

tb.addColumn(tbc);

}while(wdContext.nodeColumnSelezionati().moveNext() != null);

container.addChild(tb);

wdContext.nodeIt_Equnr().setLeadSelection(-1);

//@@end

}

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

But why dynamic text views? Why not a table?

Thanks,

Rajit

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Sonal

In addition to already mentioned answer about using a separate UI container... During a new element creation you can leave ID as NULL like

view.createElement(IWDInputField.class, null);

This will avoid recreation of UI controls with the same ID.

BR

Sergei

Former Member
0 Kudos

Hi Sergei

That seems to be very nice suggestion !! But just let me know during recreation only the ids are to kept null ? For first time we need to give ids?

Former Member
0 Kudos

Hi,

Give it a try.

Create a seperate view for these elements only. Add this view as a view container UI element.

Destroy and create at will within this View..

Regards

Bharathwaj

Former Member
0 Kudos

Please read the Javadoc. If you pass null as ID to view.createElement(), a unique ID is created automatically.

Armin

Former Member
0 Kudos

Hi All

I found the method resetView() which solved my problem. Thanks for your support.

Regards

Sonal Mangla

Former Member
0 Kudos

Hi,

First of all: usually a table is used for displaying records (Collections).

You can use a table with Textview as TableCellEditor.

If you don't want to do this, you must use destroyAllChildren to clear the view elements. You can place the textviews in a container (e.g. IWDTransparantContainer) and thus only destroy the children in this container using the destroyAllChildren method of that container.

Good luck.

Roelof

Former Member
0 Kudos

Thanks Roelof

I tried this also but actually i cannot put table headers in seperate table and data in seperate table. This may cause misalignment of columns. The data will not appear exactly below the headers