cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByKey loading questions

former_member540174
Participant
0 Kudos

I have a node populated in my custom controller that contains key/value pair. I would like to put this in a drop down by key. I've gone wrong somewhere.

Context ---

CourseList

---Objid

---Stext

Layout contains

DropDownByKey

id=CourseListByKey

selectedKey=CourseList.Stext

Code to load the simple value set


IWDAttributeInfo attributeInfo = wdContext.nodeCourseList().getNodeInfo().getAttribute("Objid");
ISimpleTypeModifiable attribNameType = attributeInfo.getModifiableSimpleType();
IModifiableSimpleValueSet valueSet = attribNameType.getSVServices().getModifiableSimpleValueSet();
//	Clear previous data
valueSet.clear();

int nodeLength = wdContext.nodeEventtype_List().size();
for (int i = 0; i < nodeLength; i++) 
{
	valueSet.put(((IPrivateSelectionView.IEventtype_ListElement)(wdContext.nodeEventtype_List().getElementAt(i))).getObjid(),
	             ((IPrivateSelectionView.IEventtype_ListElement)(wdContext.nodeEventtype_List().getElementAt(i))).getStext());
}

I am getting an error MappedAttributeInfo(SelectionView.CourseList.Objid): must not modify the datatype of a mapped attribute

Where am I going wrong?

Diane

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi diane,

Your node is mapped from view to controller.So you cant modify the context attributes inside view.Thats why you are getting this message.Please use the same piece of code inside controller to resolve this issue

Answers (6)

Answers (6)

former_member540174
Participant
0 Kudos

I put the code that obtains the data and then builds the value set in the component controller. How do I get the value set over to the Selection view?


int nodeLength = wdContext.nodeEventtype_List().size();
for (int i = 0; i < nodeLength; i++) 
{
	valueSet.put(((IPrivateManagerMassRosterCust.IEventtype_ListElement)(wdContext.nodeEventtype_List().getElementAt(i))).getObjid(),
				 ((IPrivateManagerMassRosterCust.IEventtype_ListElement)(wdContext.nodeEventtype_List().getElementAt(i))).getStext());
}
// Place valueset in context   <==== the following is not functional
ICourseValueSetElement elemVS = wdContext.nodeCourseValueSet().createCourseValueSetElement();
elemVS.setValueSet(valueSet);

How do I get the value set over to the Selection view? My assumption is to build a node and element and then add the element to the node.

Diane

former_member485701
Active Participant
0 Kudos

Hi,

If you build the value set in component controller then add the same context node & attribute

in your selection view controller. And now map this to the component controller.

Now when you build the value set in component controller, it will also be reflected in the same attribute in selection view controller.

Regards,

Praveen

former_member540174
Participant
0 Kudos

I've moved the code to create the valueset into the custom controller. I then have this node in both the view and custom controller the element is of type com.sap.typeservices.IModifiableSimpleValueSet. Now the view layout will not allow me to bind to the element.

I think I'm making this too hard. I mean all I'm wanting to do is take the results from a function module and put them in a drop down (piece of cake type coding from my .Net/C# days). Is there a tutorial, blog, or sample code from you that shows me how to build a drop down from data returned from a function module?

Getting a bit frustrated,

Diane

Former Member
0 Kudos

Hi,

Pl go through

Regards

Ayyapparaj

Former Member
0 Kudos

Hi..

Place the code to load the simple value set in component controller....

Regards

Akshaya

Former Member
0 Kudos

hi,

I had the same problem before. Remove the mapping between the component controller and view controller for this node and attribute. Create a separate node in the view Controller itself and directly access it.

former_member485701
Active Participant
0 Kudos

Hi,

You have two controller's and you are mapping the nodes between two.

(a) mapped node

(b) origin node

you are mapping your mapped node from one controller's context to origin node of other one.

This error is coming because you are modifying the attribute in mapped node. Two ways to avoid this problem.

(1). delete the mapping between the mapped node and origin node

(2). populate the value set in origin node

Regards,

Praveen

Former Member
0 Kudos

If this attribute is inside a node mapped to some other (e.g. the component) controller, you have to modify the value set at the "mapping origin" node.

Armin