cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with Context and UI

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use DropDownByIndex instead of DropDownByKey and use manke the childNode singleton to true.

Regards,

Sowjanya.

Former Member
0 Kudos

Hey Sowjanya,

1. Why use DropDownByIndex instead of DropDownByKey ?

2. I've changed the childNode singleton to true but now I can't use the bind method at this line:

newEmployee.nodeDetails().bind(newDetails);

Former Member
0 Kudos

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

Former Member
0 Kudos

Hey Valery,

I am getting the data from an LDAP Server and if I'll do a seperate loop for the supply function of details I'll have to connect and query the LDAP again, Why not doing it in a single loop as I tried?

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello Vallery,

I did all that exactlly but it doesn't seem to update the Text view.

Please read my first post for details and add to it the empty onSelect method I've added after I've read your last post(By the way, whay empty?) and correct me if I'm wrong.

Former Member
0 Kudos

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

Former Member
0 Kudos

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...

Former Member
0 Kudos

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

Former Member
0 Kudos

Hey VS,

Still doesn't work...

Former Member
0 Kudos

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.

Former Member
0 Kudos

And if I want to use DropDownByKey will it be OK as well?

Former Member
0 Kudos

No U have to use DropDownByIndex

then only u will get the values of the child node corresponding to the parent node's lead selection.

Regards,

Sowjanya.

Former Member
0 Kudos

It is working Sowjanya 10X!

Former Member
0 Kudos

And it doesn't know if I use DropDownByKey? Why? What is the difference?

Former Member
0 Kudos

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.

Former Member
0 Kudos

Much clearer, 10X.

And thank you all again for your great help and support, you amaze me each time with your deep knowledge and tolerance!

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hey Bhardwaj

Then he has to poulate the Name and address in that single node only ywrite but what i see is he is populating in two different nodes then where is the link between these nodes for specifying this ID has this name

please correct me if i am wrong

Former Member
0 Kudos

Sorry

i did not see that this is a child node

then i think u were right

Wishes

Krishna Kanth

Former Member
0 Kudos

Hey Bharathwaj,

Your solution doesn't seem to work.

Perhaps I don't quite understand the path you want me to follow.

Assuming my Context has the same structure I've described at the begining of the Post, can you please show me update line in details?

Former Member
0 Kudos

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...?

Former Member
0 Kudos

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