cancel
Showing results for 
Search instead for 
Did you mean: 

Change lead element in Drop Down by Key

S0019300750
Contributor
0 Kudos

Hi all

I have a DropDown By Key UI element bound to Value Attribute of type String.

I want to change Lead Selection element later on when user changes the other dropdowns.

Please tell me how to set Lead element in drop down by Key ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Make the cardinality of the node to which you are binfding the dropdown to 1....n .. and witnin the code collect all the values within a List( java.util) and map that list to currentcontext element of the node to which you r mapping your drp down.. Populate values in a list and bound that list like the followng wcContext.current<node>element.bind(List);

It will surely work.

Thanks and Regards

Avijit

S0019300750
Contributor
0 Kudos

Thanks Avjit

But I wonder why doesnt NWDS allow me change the cardinallity of model node which I have already mapped with custom controllers's node which is finally mapped with models node ?

Former Member
0 Kudos

This is not allowed in NWDS and does'nt make sense at all.

S0019300750
Contributor
0 Kudos

Hi Amit

I mean to say that the cardinality field is not editable.

I cannot change the the value from 0...n to 1..n

Former Member
0 Kudos

Hi Vinod,

Well thats right.What I am saying is that you cannot modify the model attribute properties which is not allowed by the Framework.The reason for which is obvious.Take an example of a SOAP webservice imported as a Model in this case.

Now if you are aware with the WD phase model the data from the request is copied into the data container initially in a client-protocol independent form.

From there it is parsed and populated into the context.Here imagine changing the context attribute cardinality or type and you can see that the request will never go beyond the validation phase which occurs subsquently.

Framework takes care of this for us by not allowing to change the properties.

Regards

Amit

S0019300750
Contributor
0 Kudos

Hi Amit

Thanks a lot for ur answer.

My requirement is like this:

One dropdown will have Vendor Numbers.

Other will have its business status values A,B,C, D.

If some vendor is selected its corresponding business status should be leadselection element in 2nd dropdown.

If some vendor dont have business status among these values, 2nd drop down should be blank as lead selection and A,B,C,D as remaing values, so that the user can change its business status and save it.

I am able to select the A,B,C, or D as lead selection element ,

but not when it is blank.

Please suggest the solution:

Former Member
0 Kudos

strange.. you would have obviously used the event to trigger the lead selection.

Ok...there's an alternative to this:

create a boolean attribute and set a condition in the wdDoModifyView().Now get the DDBI element object and set the selected value explicitly to in that particular case (i.e empty string) through the UI element object.

I hope this should work.

Regards

Amit

Former Member
0 Kudos

Hai vinod ,

simply create a node as like output model node, after executing the model, simply copy the elements from model node your duplicate node using wdcopyservice.

WDCopyService.copyElements(modelnode, dupnode).

bind duplicate node to dd. change cardinality to 1..n.

this may solve your problem.

Regards,

Naga

Former Member
0 Kudos

Hi,

What i propose is you use DropDownByKey for bussines status.

When you populate your DropDownByKey for bussiness staus using valueset,

before starting the for loop set a key valu pair for default value.

valueSet.put("Default","Choose bussiness status"); // if you want you can set the value null.

// start you for loop

When ever you select a vendor name a event is triggered.

In that event you get the bussines status code for that vendor.

Now loop through the Node for bussiness stauts and compare the key value of the business status with

the status of the vendor selected anf if they match set that as the value of the node.

Consider

Business stautus drop down visible values

Choose bussiness status

A

B

C

D

Bussiness status of the vendor selected is "B" and set in the context attribute say VendorBusinessStatus

for(i=0;i<nodeBussinessStatus.size;i++)

{

if(wdContext.currentBussinessStatus.elementAt(i).getStatus()==wdContext.currentContextElement.getVendorBusinessStatus)

{

wdContext.currentBussinessStatus.setStatus(wdContext.currentContextElement.getVendorBusinessStatus);

break;

}

else

{

wdContext.currentBussinessStatus.setStatus("Default");

}

}

S0019300750
Contributor
0 Kudos

Hello Shriram

Thanks for ur answer.

Could you pls tell me how to use valueset.

I mean how to bind it with DropDown by Key UI ?

Former Member
0 Kudos

Hi,

Assuming the context to be as below

<b>Context

--BusinessStatus (node)

-


StatusCode (attribute) // this will have the code of the status

-


StatusDescription (attribute) // this attribute should be mapped to the selectedKey property of the DDBK.</b>

If you have mapped you context from component controller to view context then

create a method in Component Controller say populateStatus and write the below code in that method

call this method in your view's wdDoinit();

IWDAttributeInfo atrInfo = wdContext.nodeBusinessStatus().getNodeInfo().getAttribute("StatusDescription");

IModifiableSimpleValueSet ValueSet = atrInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

ValueSet.put("Default","Select status");

for(int i = 0; i < wdContext.nodeBusinessStatus.size();i++)

{

ValueSet.put(wdContext.nodeBusinessStatus().getBusinessStatusElementAt(i).getStatusCode(), wdContext.nodeBusinessStatus().getBusinessStatusElementAt(i).getStatusDescription());

}

While saving this selected status for vendor get the status code as below.

wdContext.currentBusinessStatusElement.getLeadSelection();

This will give you the StatusCode and not the Status Description that is displayed in the DropDownByKey.

If this does not help you then paste your context structure here we will help you.

monalisa_biswal
Contributor
0 Kudos

To set blank as lead selection for drop down by index.

Use wdContext.current<Node>Element.setLeadSelection(-1);

For drop down by key

Use wdContext.current<Node>Element.set<attributename>(null);

Answers (4)

Answers (4)

S0019300750
Contributor
0 Kudos

Thanks to all

Former Member
0 Kudos

Vinod,

Well what Shriram suggested itself is completely wrong and makes no sense in the scenario you stated.

Let me put it this way if there is something like a DDByKey then you'll nessecarily be requiring to create a dictionary simple type without which you will not be able to

bind the UI element.

Regards

Amit

S0019300750
Contributor
0 Kudos

Hello All

Thanks for ur cordial help.

Finally My problem is solved with DropDown By Index where I was able to set blank as lead element using -1 as index.

Joseph_BERTHE
Active Contributor
0 Kudos

Hi,

You can't do it automatically with a dropdownbykey. If you want it, two solutions :

- 1 - On the onAction of the UI element, just change the lead.

- 2 - Use the dropdownbyindex, and like this the lead selection will move when the user select something.

Regards

S0019300750
Contributor
0 Kudos

Thanks Amit n Berthe..

Ok I ll use DropDown by Index. I have bound this DropDown with model node.

But its bringing with it, one blank entry. I want to remove it.

I tried to change the cardinality but its not editable.

Please suggest a way.

Former Member
0 Kudos

If you've decided to use the DDBI in and you are binding it to a model attribute of type list.

I would suggest that you'll have to filter the list programatically for the empty string that you're getting from the model and then show it at runtime.

Amit

Former Member
0 Kudos

Hi Vinod,

The attribute to which you've bound the DDBKEY element holds the key and displays the value at runtime.In your case you'll require to set the attribute to some default key that you want as the leadSelection and so the lead selection

can be changed by manipulating the same attribute keys.

Regards

Amit