on 06-02-2005 7:16 AM
Hello,
I am getting employees details from a certain repository
Each employee details contain the following info - ID, Name and Address.
I would like to create the following UI for it:
A DropDown by Key which will contain the employees IDs.
Each selection of an ID shows the relevant employee details on Text Views.
In order to acheive this I've created the relevant UI and this Contex:
At the context root I've created a Context Node called AllEmployees and inside it I've created an ID ttribute (called employeeID) Aand a Context Node with cardinality 1...1 by the name Details which contains the Name and Address Attributes.
I bounded each UI to it's relevant Context and initialized it like this:
I
PrivateMainView.IAllEmployeesElement newEmployee;
PrivateMainView.IDetailsElement newDetails;
ISimpleTypeModifiable idType = wdThis.wdGetAPI().getContext().getModifiableTypeOf("AllEmployees.employeeID");
IModifiableSimpleValueSet idValues = idType.getSVServices().getModifiableSimpleValueSet();
while(...)
{
newEmployee = wdContext.createAllEmployeesElement();
newEmployee.setEmployeeID(id);
idValues.put(id,id);
wdContext.nodeAllEmployees().addElement(newEmployee);
newDetails = wdContext.createDetailsElement();
newDetails.setName(name);
newDetails.setAddress(address);
newEmployee.nodeDetails().bind(newDetails);
}
The result is that the DropDown contains the IDs but selecting and ID doesn't result in showing the relevant details on the Text Views.
Can anyone please help me with that?
Hi,
Use DropDownByIndex instead of DropDownByKey and use manke the childNode singleton to true.
Regards,
Sowjanya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Roy,
1. Use *ByIndex variant or table when you have <b>list of elements</b>, use *ByKey if you have defined <b>enumeration of attribute's value</b>. In fact you may convert bewteen 2 options (and you <b>do</b>) but why waste time?
2. Alter "bind" to a supplying relation role (if you are using Adaptive RFC model) or create a supply function for Details node and add details here.
I just re-read the thread and whant to emphasise how (1) rule simplifies your life -- no need to populate SVS, no need to convert selection of ID to navigation in your own structures -- everything handled by WD automatically.
VS
Message was edited by: Valery Silaev
Ooops!
Then you are right -- you need to download as much data at once as possible. Also you <b>should not</b> use singleton for details in this case.
Try the following approach:
1. Create context:
-- AllEmployees (0..n, singleton)
+-- EmployeeDetails (0..1, non-singleton)
2. Populate complete tree on start (both AllEmployees node and details for every IAllEmployeesElement).
3. Then bind DropDownByIndex (DDI) to AllEmployees node, and assign all the "details" UI control to EmployeeDetails node attributes.
4. Create empty onSelect action for DDI.
All the rest is WD magic
VS
1. Empty onSelect is required to force WD client submit event to server -- after this WD run-time navigates in AllEmployees node automatically and updates UI correspondingly
2. If you are using your original code, then you are wrong:
A. Make Details node node-singleton!
B. After creating employee element do the following:
final IPrivate<Controller>IDetailsNode nodeDetails = elEmployee.nodeDetails();
final I<Controller>IDetailsElement elDetails
= nodeDetails.createDetailsElement();
/* populate details attributes */
nodeDetails.addElement(elDetails);
VS
Hey Valery,
1. Why is it importent to set the Details node as Singeltone? Does this mean that it will create new Node for each employee element? If yes, isn't this what the cardinality does or Am I mixing things up?
2. While trying to implement your code I fall at this line:
final IPrivate<Controller>IDetailsNode nodeDetails = elEmployee.nodeDetails();
my elEmployee has only the node() method but not the nodeDetails() method...
1. You mixing things indeed. Cardinality defines whether node contains one or many elements. Singleton defines whether child node will be created for selected parent element (and re-created after selection chenged) or will be created for every parent element.
2. So make details non-singleton.
VS
Hi,
Check this out.
for(int i=0;i<10;i++)
{
IPrivateTestAppView.IVnEmployeeElement neEmp =wdContext.createVnEmployeeElement();
neEmp.setVaID(""+i);
wdContext.nodeVnEmployee().addElement(neEmp);
IPrivateTestAppView.IVnDetailsElement neDet = wdContext.createVnDetailsElement();
neDet.setVaName("Text"+i);
neEmp.nodeVnDetails().addElement(neDet);
}
Now create a dummy action for DropDownByIndex UI element.
The problem might be u didnot still make the childNode as non-singleton.
This is perfectly working.I checked it out.
Regards,
Sowjanya.
Hi,
If u use DropDownByKey then the u will enumeration for the attribute and all the values correpsonds to a single node instance.
But If u use DropDownByIndex and bind it to a value attribute under a node with cardinality 0-n then u will have 0-n instances for that node and each value in the dropdown corresponds to an instance.
In ur case u have child node and for each parent node of cardinality 0-n u will have values for the child nodes.
So here in this case it is appropriate to use DropDownByIndex.
Hope it is a bit clear now.
Regards,
Sowjanya.
Hi,
What u are doing here is creating elements and populating the node. This will just populate the dropdown..
When u select a particular value in a dropdown it will become the currentnodeelement.
For displaying corresponding values do the following:
1. create a action for onSelect
2. INside that if textview is assigned to attr textdata
wdContext.currentContextelement.setTextdata(wdCOntext.node<name>.currentnode<element>.get<val>());
Can u get wat i am saying!
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can see what the problem is:
When I go to the current element of AllEmployees I am able to get the current ID but when I go to it's sub-node Details I get the Name and the Address of the last populated element which means that selecting an ID doesn't update the Details element. It seems like they are not bound to each other although I bound them at the code. Any ideas...?
cant u have the Name and Address Attributes in the All Employees Node itself and then for each instance of that u can have it generated so that onAction of that u can call that partocular node instance and display the Values
This is just a thinking.
Wishes
Krishna kanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.