on 2007 Mar 01 1:35 AM
Hello all.
I created in the wdInit()
ArrayList datas = new ArrayList();
for (int i = 0; i < 25; i++) {
MyData data = new MyData();
....
data.setMethods();
....
datas.add(data);
}
wdContext.nodeMyData().bind(datas);
Now, I want by clicking on the Button "Create new Element", forward user to the other View, which elements are connected with the same model -> context, the new element should be added to context, the user should fill the form and click Save-Button.
How can I add a new Element to the Collection I created and choose it as a current element?
If I do: wdContext.nodeMyData().bind(new MyData()) all information will be lost. And I will have only one field.
If I do it like this:
IWDNodeElement dynTabElem=(IWDNodeElement)wdContext.nodeMyData().createElement();
wdContext.nodeMyData().addElement(dynTabElem);
I get an error: com.sap.tc.webdynpro.progmodel.context.ContextException: NodeInfo(DataComp.MyData): value node is created without a reference
Well I can pass to my new View a Collection as a parameter and then
Collection.add(new MyData()) and then bind it. But I find this solution not good.
Is there any possibility to get the existing Collection from the Context without passing it to the view?
Can I just add a new element to the existing collection?
Thanks in advance.
For model nodes you can't directly add elements to the node.
1>Take reference of parent model class.
<Parent Model Class> <ref>=wdContext.current<Parent Model Node>Element().modelObject();
2>Add elements to the collection>
<ref>.add<Collection Name>(new <SubNode Model class>());
3><invalidate model node>
wdContext.node<SubNode>().invalidate();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alex,
MyData newData = new MyData();
/* Some setup for model object, optional
newData.setMethods();
*/
IWDNodeElement dynTabElem=(IWDNodeElement)wdContext.nodeMyData().createMyDataElement(newData);
wdContext.nodeMyData().addElement(dynTabElem);
Valery Silaev
SaM Solutions
User | Count |
---|---|
66 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.