cancel
Showing results for 
Search instead for 
Did you mean: 

Writable Calculated Context Attributes - setter method

Former Member
0 Kudos

According to the SAP documentation the setter method for writable calculated field is only called by the Web Dynpro runtime environment if the value of the writable calculated context attribute was changed in the user interface before an action was triggered.

I have added a calculated attribute to the model node of component controller and bound it to the input field in the view.

But in my case the setter method is never called by the WEB Dynpro runtime.

I want to use a setter method to validate user input.

Should I call a setter method explicitly in the action method?

Thanks,

Julia

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Julia.

It should function exactly like in the documentation.

1. have a model node from backend

2. create an additional value node either as child-node to the modelnode or directly as child to Context root.

3. set the value nodes cardinality and singelton properties as needed.

4. create calculated attributes and bind them to input fields.

If you don't have an element in the value node with attributes bounded to the input fields, the fields would be disabled. I don't think this is your problem.

Make sure the inputfields are bound to the correct attributes.

Make sure the value node has correct cardinality settings, singelton settings.

Make sure the value node doesn't have any mapping references to the controller while the setter method is in the view.

I can't think of anything else...

Regards, Mikael

Former Member
0 Kudos

Mike,

I have thought that the setter method is not being called but it actually was called; I have a "reportMesssage" call in the body of the setter method and reportMessage was not reporting anything. But the rest of the setter method worked.

I have an attribute in the model node that called fromYear, it is 4 chars long. I have created a context attribute in the model node of the view fromYearCalc, type String and calculated.

I use fromYearCalc attribute to set / get the value of the fromYear

Now the problem that I am having with using calculated field is that I can not leave the user entered errored value in the node fromYear and have to blank it in order for validation to work properly.

If I leave the errored value and the user does not change it and press the action button again, the setter method is no longer being called and the errored value is going through.

Is it the way the calculated node is suppose to work?

Julia

Edited by: Julia Shapiro on Mar 3, 2008 4:31 PM

Former Member
0 Kudos

Hi.

Yes, that's true. You can't use reportMessage from inside a set method of a calculated field.

I think the method manager is either not avalible at that time, or is cleared after you use it in the setter method.

You can write any message reporting in the getter methods of the same attribute. (Let the setter method set the incorrect value, and report the error with the getter method "on the way back" from the request response loop)

Regards, Mikael

Edited by: Mikael Löwgren on Mar 3, 2008 5:18 PM

Former Member
0 Kudos

Mikael,

Can you please send me an example of the code?

The rule is that fromYear attribute should be numeric between 1998 and 2050

Julia

Answers (0)