on 07-27-2005 10:49 AM
Hello,
I have a Node : Passenger
Name
Age
Sex
Choice
I am adding elements to this node dynamically.
So it looks like this at run time
Passenger 1
Shubham
27
M
...
Passenger 2
Mohana
26
F
...
I am creating a dynamic screen that will show the data in the above nodes and an inputfield to get the passenger food choice. So at run time my screen looks like
Name: Shubham
Age : 27
Sex : M
Choice : _______
Name: Mohana
Age : 26
Sex : F
Choice : _______
I want to bind the input fields above to each node instances. If the user fills in the data as
Veg in first input box and N/Veg in the second input box, my nodes should look like.
Passenger 1
Shubham
27
M
Veg
Passenger 2
Mohana
26
F
N/Veg
Please give your valuable inputs as to how to achieve this. A Code sample will be great.
Thanks and Regards,
Shubham
Hello Shubham,
there is no way to achieve the same effect that a Table in Web Dynpro does without using a Table. I mean you cannot bind an InputField to the second element of a node. You can only bind it to an attribute, and that attribute is always taken from the element that currently has the lead selection.
So if you want to avoid a table and have a form-like layout of input fields instead, you need to create a different context node for each passenger object.
I guess the others gave all hints on how to do that. I just want to point out that there is no other way.
Best regards,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think it should work like this.
First you create a node say 'passenger'.
Under that you add the attributes that you want say 'name' 'age'.
Now create another node say 'choice' as a child node of the top node passenger. Now add the attribute say 'value' under the node 'choice'. Now set the singleton property of the child node 'choice' to false ie. Make it non singleton. Now you can create the as many elements of the top node 'passenger' as you want. And for each element you create you will have separate node instance of the child node 'choice'. So each element of parent node passenger will have its own corresponding elements under child node choice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Can we make use of Recursive nodes for this ?? Any Ideas ??
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Subham,
AS far I know, we don't bind UI elements to elements of a node. As you know we bind them to attributes. The concept is similar to that of class & object. We bind it to a class & the objects of the class are created at runtime through which we populate them. So, when it expects a class, we can't substitute it with an object.
This is my understanding and I 'll be only delighted if if someone proves this wrong with a better explanation.
I think you can get your problem solved by dynamically creating as many attributes as the inputfields and binding them.
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.
Hi Nibu,
Yes you are correct. But since I am dynamically building the context and creating the UI, at run time I will have a Object which I should bind to the the inputfield. I want to know how is that possible. The table UI Element acheives the same at runtime.
I dont want to do a work around by creating as many attributes at runtime as the no of input fields and then build my context table from these attributes at runtime since this can be a very time consuming operation at runtime.
Any inputs are welcome.
Regards,
Shubham
hi subham,
I mistook your question.I thought that you want it all dynamoically
Any way it is not possible to bind elements of node to UI elements
You can do one thing
Show this in a table
on selection get the lead selection element and display it in text views and input fields so that user can edit it
Create context attributes for passenger no,name....
Also create a node with these attributes
Pass values from nodal elements into these context attributes during runtime and get their attribute info and use them for setting the text
If details is the node and age name.. are attributes
IPrivateAppView.IDetailsElement element;
for(int i=0;i<wdContext.nodeDetails().size();i++)
{
//for first five use textview
IWDAttributeInfo info1 = wdContext.getNodeInfo().getAttribute("age");
IWDAttributeInfo info2 = wdContext.getNodeInfo().getAttribute("name");
IWDAttributeInfo info3 = wdContext.getNodeInfo().getAttribute("pass_no");
element = wdContext.nodeDetails().createDetailsElement();
IWDTextView text = (IWDTextView)view.createElement(IWDTextView.class,null);
wdContext.currentContextElement().setAge(element.getAge());
text.bindText(info1);
IWDInputField field = (IWDInputField)view.createElement(IWDInputField.class,null);
field.bindvalue(info3)
when context bound to the input field is changed
loop through the node using passenger number and change its value
Hope this helps you
Regards
Rohit
Hi Rohit,
Thanks for your detailed answer.
Actually this is a very crude way of achieving what I want, and I personally don't like to do things in this way. I was thinking how the Table UI Element has implemented this and there should be some ready made methods for the same.
I dont want to traverse through the node at runtime since this has a huge impact on the performance specially when the node size is big.
But since it seems like there is no option, I have to do it in the "Crude" way.
Thanks everyone for their help.
Regards,
Shubham
P.S. - I will not mark this as complete since I feel there should be something else we could do. So if anyone finds out please let me know at shubham.tripathi@gmail.com
Binding an input field to a context attribute is mandatory and you can't bind the node instances to an input field.
I would suggest that you create attributes for the input field and copy the value from the instances on to these attibutes .
or else bind the node attribte to the table.
Regards
Noufal
Hi Subham,
In the doModifyView method do the following.
Iterate through the instace elements .
//For each instance create Group UIElement
// In each group add the UIElements lable and inputfield for the each valueattribute in the instance.
//Bind the inputfield with the respective attribute.
I am sorry....I understood your question wrongly.Please ignore my posting
Regards, Anilkumar
Message was edited by: Anilkumar Vippagunta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Subham,
Why can't you use Table UI Element to do this?
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shubham,
create the node as follows
IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("node1",null,true,false,true,false,false, true,null,null, null);
IWDNodeInfo nodeInfo1 = wdContext.getNodeInfo().getChild("node1");
// Dynamically add attributes to the context node
nodeInfo.addAttribute("Name","com.sap.dictionary.string");
Like this you add the attributes
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("node1",IWDNode.LEAD_SELECTION);
enter elements as follows
IWDNode node = wdContext.getChildNode("node1",IWDNode.LEAD_SELECTION);
IWDNodeElement element;
loop
{
element = node.createElement();
element.setAttributeValue("attribute1",value);
element.setAttributeValue("attribute2",value);
}
creating UI elements
Write in modify view
IWDTextview text = (IWDTextview)view,createElement(IWDTextview.class,null)
text.bindText(<whatever text is to bound>)
IWDInputField field = (IWDInputField)view.createElement(IWDInputField.class,null);
field.bindValue( node.getElementAt(<give index>).getAttribute())
Hope this helps you
Regards
Rohit
Message was edited by: Rohit Radhakrishnan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rohit,
field.bindValue( node.getElementAt(<give index>).getAttribute())
Actually this is the statement where I am stuck up. The bindValue menthod, takes the path of the attribute in the context. In my example it is "passenger.choice".
Now what happens at runtime this points to the lead selection of the node.
So if I enter, veg and non veg in the two input fields, the value of the first input box also becomes non veg.
Regards,
Shubham
How many elements are you going to add to the nodes and how many are you going to display in the view?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.