cancel
Showing results for 
Search instead for 
Did you mean: 

OVS access to a IModifiableSimpleValueSet variable in view

0 Kudos

Hi,

we have a WebDynpro application. We also have a view with several input fields. One of this field (type string, name "customer") is changed to use a ISimpleTypeModifiableValueSet as a kind of value help. This works pretty good.

Also there is an inpute field which is connected to an OVS in a custom controller (type string, name "material"). But for the OVS help it is neccessary to access the value of "customer". My problem is, that I can't map "customer" because the type is changed. My second idea was to copy the value of "customer" to another varaible, which is mapped. But if I just enter a new value for "customer" without use the selector, the new value will not be copied if I call the "material" OVS.

Is there a solution how I can access a variable in the view from the custom controller?

Regards, Nils.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nils,

When you say "customer" is changed to use a ISimpleTypeModifiableValueSet, I assume, you have created a valueset for this string attribute, and have populated the valueset through the valueset.put(key,value) method. If this is the case and if you have access to the valueset data (the keys & values to be populated into the string attribute) from the component controller, this is what you can do:

1) Create a string attribute in component controller. Now map the string attribute of the view to this component controller attribute .

2) Since the view attribute is mapped, you cannot create the valueset for this attribute in the view. Instead, use the same code to populate the component controller attribute inside the component controller. This will be reflected in the view attribute as well.

3) Now you have valueset attribute in both component & view and which are mapped. Since any selection in view will be reflected in the component, you can very well access the component attribute to get the latest data.

Hope this helps,

Best Regards,

Nibu.

0 Kudos

Hi Nibu,

> When you say "customer" is changed to use a

> ISimpleTypeModifiableValueSet, I assume, you have

> created a valueset for this string attribute, and

> have populated the valueset through the

> valueset.put(key,value) method.

That's right, I use the valueset.put method.

> If this is the case

> and if you have access to the valueset data (the keys

> & values to be populated into the string attribute)

> from the component controller, this is what you can

> do:

Ok, I can access the datas.

> 1) Create a string attribute in component controller.

> Now map the string attribute of the view to this

> component controller attribute.

Ok, done.

> 2) Since the view attribute is mapped, you cannot

> create the valueset for this attribute in the view.

> Instead, use the same code to populate the component

> controller attribute inside the component controller.

> This will be reflected in the view attribute as

> well.

Ok, I've copied and adapted the code to the custom controller, also I removed (commented) the corresponding lines in the view code.

But now the view will see just a string value, won't it?

Or should I leave some code in the view that will change the type of the "customer" value.

> 3) Now you have valueset attribute in both component

> & view and which are mapped. Since any selection in

> view will be reflected in the component, you can very

> well access the component attribute to get the latest

> data.

Even if I leave some code so in both the view and the custom controller the type of my string value will be changed to the ISimpleTypeModifiable I get the exception:

must not modify the datatype of a mapped attribute.

So thei won't help.

Regards, Nils.

Former Member
0 Kudos

Hi Nils,

2) No you needn't write any code in view for modifying the attribute (in fact you won't be allowed too). Since the attributes are mapped, when you create an enumeration for the component attribute, the same will be applied for the view attribute as well

3) The exception is because of the code you have written in your view. When you map a view attribute to a component attribute, the comp attribute will be considered as the data source for the view attribute. So you will not be allowed to change the view attribute, bcos, then the target attribute may have a different type than the source attribute. But if you populate the component attribute through a valueset, the values will automatically copied by the mapped view attribute.

Hope this helps,

Best Regards,

Nibu.

0 Kudos

Hi Nibu,

> 2) No you needn't write any code in view for

> modifying the attribute (in fact you won't be allowed

> too). Since the attributes are mapped, when you

> create an enumeration for the component attribute,

> the same will be applied for the view attribute as

> well

Ok, I have removed the code.

> 3) The exception is because of the code you have

> written in your view. When you map a view attribute

> to a component attribute, the comp attribute will be

> considered as the data source for the view attribute.

> So you will not be allowed to change the view

> attribute, bcos, then the target attribute may have a

> different type than the source attribute. But if you

> populate the component attribute through a valueset,

> the values will automatically copied by the mapped

> view attribute.

I get the exception in the custom controller while executing the following line:

ISimpleTypeModifiable customers = wdThis().wdGetAPI().getContext().getModifiableTypeOf("Customer");

where "Customer" is my mapped value attribute.

Is this ok, that I just can map the value from the view to the custom controller, but not from the controller to the view?

Thx for help, Nils.

Former Member
0 Kudos

Hi Nils,

Between a view and a component controller, the mapping will always be from the view to the component controller. But this doesn't mean that any data change in the view attribute is not reflected in the component. But it is a kind of mutual mapping. In fact, the direction of mapping becomes very relevant only in the case of external mapping.

This code shouldn't throw you a 'trying to change a mapped attribute' exception. Can you pls confirm if you are mapping this attribute to some other attribute? The lines of code you need to write are :

IModifiableSimpleValueSet valueset = wdContext.getNodeInfo().getAttribute("attribute name").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

valueset.put(<key>,<value>);

Hope this helps,

Best Regards,

Nibu.

0 Kudos

Hi Nibu,

> This code shouldn't throw you a 'trying to change a

> mapped attribute' exception. Can you pls confirm if

> you are mapping this attribute to some other

> attribute?

You're right, there was a mapping from the custom controller to the interface, which isn't needed. So I removed it and now it works.

Great, thank you very much.

Regards, Nils.

Answers (0)