on 09-05-2007 12:04 PM
Hello friends,
is wdDoModifyView only executes only once, or always when the control comes back in view....
regards,
HI,
It would be executed every time an action is fired and even when control comes back unlike wdDoInit() which is executed only once during its entire life cycle.
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have removed the firsttime statement, and now I am getting this error:
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "Matnr" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TableColumn
so is it possible that i do clear the result table, everytime before filling the table ?
Regards,
okey,
//@@begin wdDoModifyView
IWDMessageManager mm = wdThis.wdGetAPI().getComponent().getMessageManager();
IWDTable tv = (IWDTable)view.getElement("resultTable");
tv.bindDataSource(wdContext.currentContextElement().getApplication());
int size = wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().size();
int size_fld = wdThis.wdGetDownloadControllerController().wdGetContext().nodeZvar_Fld().size();
String omit_field = "";
ArrayList omit_list = new ArrayList();
for (int a = 0; a < size_fld; a ++ ) {
omit_field = wdThis.wdGetDownloadControllerController().wdGetContext().nodeZvar_Fld().getZvar_FldElementAt(a).getAttributeValue("Fieldname").toString();
omit_list.add(a, omit_field);
}
// if (firstTime)
// {
tv.removeAllGroupedColumns();
for (int i = 0; i < size; i++)
{
String fieldName =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getFieldname()
.toLowerCase();
String rangeType =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
if (rangeType.compareToIgnoreCase("to") != 0)
{
String fieldText =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
fieldName = WDUtil.getJavaNameForAbapFieldName(fieldName);
String attrName = wdContext.currentContextElement().getApplication() + "." + fieldName;
String testfield = fieldName.toUpperCase();
if ( omit_list.contains(testfield)) {
//mm.reportSuccess("this is omit field" + testfield);
} else {
//tv.removeAllColumns();
IWDTableColumn column = (IWDTableColumn)view.createElement(IWDTableColumn.class, fieldName);
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);
IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class, null);
column.setTableCellEditor(textView);
column.setHeader(caption);
textView.bindText(attrName);
caption.setText(fieldText);
tv.addColumn(column);
}
// if (fieldName.equalsIgnoreCase("VBELN")) {
//
// mm.reportSuccess("This is vbeln");
// } else {
// IWDTableColumn column = (IWDTableColumn)view.createElement(IWDTableColumn.class, fieldName);
// IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);
// IWDCaption caption = (IWDCaption)view.createElement(IWDCaption.class, null);
// column.setTableCellEditor(textView);
// column.setHeader(caption);
// textView.bindText(attrName);
// caption.setText(fieldText);
// tv.addColumn(column);
// //}
// if (fieldName.equalsIgnoreCase("VBELN")) {
//WDVisibility visibility = (WDVisibility)column.getVisible();
//column.setVisible(WDVisibility.NONE);
}
// column.setHeader(caption);
// textView.bindText(attrName);
// caption.setText(fieldText);
// tv.addColumn(column);
// }
}
saveColumns = tv.getColumns();
// }
if (rebuildScreen)
{
IWDTableColumn[] tcArray = saveColumns;
tv.removeAllColumns();
Map hMap = new HashMap();
for (int x = 0; x < tcArray.length; x++)
{
IWDTableColumn tc = (IWDTableColumn)tcArray[x];
String tcID = tc.getId();
for (int i = 0; i < size; i++)
{
boolean omit =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getOmit();
String dispSeq =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getDispseq();
String fieldName =
wdThis
.wdGetFieldControllerController()
.wdGetContext()
.nodeZfld_Name()
.getZfld_NameElementAt(i)
.getFieldname();
String rangeType =
wdThis.wdGetFieldControllerController().wdGetContext().nodeZfld_Name().getZfld_NameElementAt(i).getDdtext();
if (rangeType.compareToIgnoreCase("to") != 0)
{
fieldName = WDUtil.getJavaNameForAbapFieldName(fieldName);
if (tcID.equals(fieldName) && dispSeq.trim().length() > 0 && omit == false)
{
hMap.put(dispSeq, tcArray[x]);
}
}
}
}
Map sortedMap = new TreeMap(hMap);
Iterator iter = sortedMap.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
IWDTableColumn tc = (IWDTableColumn)entry.getValue();
tv.addColumn(tc);
}
tv.setFirstVisibleRow(0);
wdContext.currentContextElement().setTableSorter(new TableSorter(tv, wdThis.wdGetSortAction(), null));
}
rebuildScreen = false;
//@@end
Regards,
The problem with your previous code was that modify view was called more than once and again and again it was trying to create a column with the same name and thus it resulted into an error.
When we reset the view all the dynamically created contents will be removed and thus even if modify view is called again it will allow you to create those columns with the same name.
But man this is not a good approach as wdDoModifyView is called manier times and everytime you are creating those columns dynamically it should generally be within if(firstTime) block so that those creation won't take place again and again.
But your requirement asked it to be created everytime.
So this is how it works.
Regards,
Murtuza
you know how it work in adhoc projects, once you created for one requirements and then later add ons
So it was first created only to display the columns, and thus firsttime statement was working fine, and now I have to adjust new customer requirement and that's why all this
any way suggest anyother approach how to do so, like instead of omitting fields in wdDomodifyview...
Seconly any good documenation which you would like to refer to understand the arch or so....
Regards,
But for any dynamic coding, you can do it only in wdDoModifyView() so no other way out. Just you can fine tune it as per your business requirement.
Cheers,
Murtuza
We had the same requirement for one of our applications. Initially we created columns dynamically but the performance was so slow. users did not like it. So alternatively we created some max number of columns at design time and depending on the data we hide or show a specific column. Performance was lot better.
Hope it helps
Regards
Firasath
wdDoModifyView() is always executed when a view is displayed
This method should only be used for modifying the view, i.e. adding/removing/rearranging UI elements.
You should not use this method to set UI element properties that also may be manipulated using data binding. Data binding is the preferred way for setting property values or changing selections
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
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.