on 11-11-2005 6:44 AM
I have want three input fields which are bound to view attributes.
users will enter the data into the fields and press the button. On clicking this button,
these values will be stored in node(cardinaltiy 0..n) and Table will be displayed at the bottom of the screen.
OnAction of Button executes
IPrivateDynTableView.IPersonElement element =
wdContext.nodePerson().createPersonElement();
element.setFirstName(wdContext.currentContextElement().getFirstName());
element.setLastName(wdContext.currentContextElement().getLastName());
element.setEMail(wdContext.currentContextElement().getEMail());
wdContext.nodePerson().addElement(element);
It is working well to add one row. After that I am getting the error 500.
Error message reads "com.sap.tc.webdynpro.services.exceptions.WDCreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView"
Context
-Person(ValueNode; Cardinaltiy 0..n)
--FirstName
--LastName
-FirstName
-LastName
public static void wdDoModifyView(
IPrivateDynTableView wdThis,
IPrivateDynTableView.IContextNode wdContext,
com.sap.tc.webdynpro.progmodel.api.IWDView view,
boolean firstTime) {
//@@begin wdDoModifyView
if (!firstTime) {
IWDTransparentContainer root =
(IWDTransparentContainer) view.getRootElement();
IWDTable table = (IWDTable) view.createElement(IWDTable.class, "table");
table.bindDataSource(wdContext.nodePerson().getNodeInfo());
IWDTableColumn colFirstName =(IWDTableColumn) view.createElement(IWDTableColumn.class,"firstName");
IWDCaption capFirstName =(IWDCaption) view.createElement(IWDCaption.class,"firstNameCap");
capFirstName.setText("First Name");
IWDTextView textViewFirstName = (IWDTextView) view.createElement(IWDTextView.class, "fname");
textViewFirstName.setText(wdContext.nodePerson().currentPersonElement().getFirstName());
colFirstName.setTableCellEditor(textViewFirstName);
colFirstName.setHeader(capFirstName);
table.addColumn(colFirstName);
IWDTableColumn colLastName =(IWDTableColumn) view.createElement(IWDTableColumn.class,"lastName");
IWDCaption capLastName =(IWDCaption) view.createElement(IWDCaption.class,"lastNameCap");
capLastName.setText("Last Name");
IWDTextView textViewLastName = (IWDTextView) view.createElement(IWDTextView.class,"lname");
textViewLastName.setText(wdContext.nodePerson().currentPersonElement().getLastName());
colLastName.setTableCellEditor(textViewLastName);
colLastName.setHeader(capLastName);
table.addColumn(colLastName);
IWDTableColumn colEMail =(IWDTableColumn) view.createElement(IWDTableColumn.class,"email");
IWDCaption capEMail =(IWDCaption)view.createElement(IWDCaption.class,"eMailCap");
capEMail.setText("Last Name");
IWDTextView textViewEMail =(IWDTextView) view.createElement(IWDTextView.class,"email");
textViewEMail.setText(wdContext.nodePerson().currentPersonElement().getEMail());
colEMail.setTableCellEditor(textViewEMail);
colEMail.setHeader(capEMail);
table.addColumn(colEMail);
root.addChild(table);
}
//@@end
}
Any ideas on re-using the table?
Thanks
~kranthi
Hi Kranthi,
In your code, you are creating UI elements everytime except for the first time.
if (!firstTime) {
.
.
IWDTable table = (IWDTable) view.createElement(IWDTable.class, "table");
.
.
So the second time, wdDoModify() is encountered, this code will throw an exception as there already exists UI elemnts with the same name. So if you want to create UI elemnts each time the page is loaded, make sure you remove all the dynamically created UI elements by writing the following line of code:
if (!firstTime) {
<b>view.resetView();</b>
.
.
Another mistake is you haven't bound the UI elements to the corresponding attribute, but have explicitly set the values. This will show the same value in eachh row of the table. So instead of
textViewFirstName.setText(wdContext.nodePerson().currentPersonElement().getFirstName());
write
<b>textViewFirstName.bindText("Person.FirstName");</b>
Similarly for the rest of the columns too.
The rest of the code looks fine.
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you simply have to add new node elements into the context. No need to recreate the table UI element every time.
Data binding:
Context:
-Person(ValueNode; Cardinality 0..n)
--FirstName
--LastName
Table.dataSource -> Person
TableColumn1:
--(TableCellEditor)TextView.text -> EMail
TableColumn2:
--(TableCellEditor)TextView.text -> FirstName
TableColumn3:
--(TableCellEditor)TextView.text -> LastName
Armin
Message was edited by: Armin Reichert
Armin,
Thanks for your reply.
I want to call wdDoModifyView() only with action. So I need to use <i>if(!firstTime)</i> condition.
By the time view changed with second action event, they are already defined. To overcome this, we are deleting the existing elements. Do u have any other ideas to overcome this?
Thanks
~kranthi
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.