cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownListByKey cahnge fires to fill another DropDropDownByKey

Former Member
0 Kudos

Hi,

I'm developing webdynpro java application.

a view in application contains 2 DropDownByKey.

First DropDownListByKey filled in component controller (Via context element).

When first DropDownListByKey's selected value changes, second DropDownListByKey must fill (in View, via context element).

I did 1st DropDown filled successully at component controller, but problem about second DropDown (in view).

Second DropDown must fill related value with 1st DropDown, Therefore it must be fill when 1st DropDown oncahange.

I gave error message at the bottom.

How can i solve this problem?

Thanks.

Note: No problem about build and run.Only runtime error .

Below is code that fills 2nd DropDownListByKey

IWDAttributeInfo attInf = wdContext.getNodeInfo().getAttribute(wdContext.currentContextElement().ELEMENT);

ISimpleTypeModifiable stm = attInf.getModifiableSimpleType();

IModifiableSimpleValueSet svs = stm.getSVServices().getModifiableSimpleValueSet();

try {

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/SAPXXXDB");

Connection con = ds.getConnection();

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select FIELD2 from ZTABLE Where FIELD1 = 1stDropDownValue");

svs.put("", "");

while (rs.next()) {

svs.put(rs.getString("ELEMENT"), rs.getString("ELEMENT"));

}

con.close();

} catch (Exception e) {

wdContext.currentContextElement().setMESSAGE(e.toString());

}

Error

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(YYYYappView.ELEMENT): must not modify the datatype of a mapped attribute

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Cemil Bozlagan,

There is no problem in your coding. That's why you are not getting build error. Actually

getModifiableSimpleType();

must not be used to mapped context attribute. Because it throws run time exception

You may have mapped this attribute wdContext.currentContextElement().ELEMENT with some other attribute in controller.

Now you have two options.

1.If you don't use this dropdown values outside the view, remove the context mapping and try with this code.

2.If you are using these values in some other places(other views or controllers) then create a method in the controller(custom/ component) where you have base attribute as Mr.Satyajit told. Copy this code into the method.

In 1st dropdown onSelect event handler just call that method of the controller.

I hope I made it clear it to you. Feel free to revert in case of any issues.

Regards,

Siva

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Where are you writing this code? In the view? Looks like this attribute "ELEMENT" is mapped between two (or more) controllers. When attributes are mapped between controllers you can only modify their datatype from the root controller.

So if you have ELEMENT mapped from the component controller to the view controller, then use the same code in component controller.

Regards,

Satyajit

Former Member
0 Kudos

Hi,

I wrote this code in View Implementation.

Element mapped from component controller context to view context.

But Element is mepped from component controller context to another views contexts also.

If i use same code in component controller how can i fire to fill 2nd DropDown on selected changed 1st dropDown?

Thanks.

Former Member
0 Kudos

Hi,

>If i use same code in component controller how can i fire to fill 2nd DropDown on selected changed 1st dropDown?

Create a public method in component controller class, put your code within this method. Call this new method from the onchange event handler of the first dropdown.

Regards,

Satyajit

Former Member
0 Kudos

I strongly reccomend not to manage data on the view contexts, only in component controller, in order to fill the 2nd dropdown u should use and fire an event from the view, and fill the 2nd dropdown on the event handler located in component controller.

The selected value from 1st dropdown should be also read from context (shared between compcontroller and viewcontroller), or passed as parameter in the event.

Regards

Julio C. Herrera