cancel
Showing results for 
Search instead for 
Did you mean: 

Type Mapping in Web Dynpro

Former Member
0 Kudos

Hi there,

rather a Web Dynpro newbie, I have scanned the documentation and forum threads to find whether there is something like a type mapping mechanism (say, your web service automatically creates Calendar attributes from xsd:dateTime elements, and you want to display them as dates in your view), but it seems there isn't.

I have to do such type conversions by myself (by providing additional value attributes to my context node and populate them after executing the service call), right? Or did I overlook something?

Regards

Nils

Accepted Solutions (1)

Accepted Solutions (1)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Nils,

define calculated context attributes of type readOnly=false for this purpose. In the generated getter and setter methods you can implement your own format (getter) and parse (setter) logic (or type mapping like you call it).

Excerpt from the Web Dynpro Help:

<i>Application-specific validations: You can use the setter and getter methods that are generated for writable calculated context attributes to format as well as parse and validate data application-specific. You can check the user input in the mutator method and save it in a separate, non-calculated context attribute. An error message is displayed if this is not successful. If you want to display the input value in the case of errors as well, then first you have to save the incorrect value in an additional usual context attribute, from which the access method of the calculated attribute is then supplied.</i>

Also read thread about problems with time input fields.

Regards, Bertram

Former Member
0 Kudos

Hi Bertram,

thanks for your reply. Your answer suggests that my intuition was right and that there is no built-in type mapping mechanism I might have overlooked.

Regards

Nils

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

To convert Date format, you have to handel this by creating an another Value attribute map this with UI element the conversion part can be handeled in Implementation(Source code).similar to the following (Get and set)

cal = r.getDate();
    wdContext.currentContextElement().setDate((cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.DATE)+"/"+cal.get(Calendar.YEAR));

hope this helps you..

RK

Former Member
0 Kudos

What you describe is the approach I had taken already, i.e. providing additional value attributes. What I wanted to know was whether there is some configurable type mapping built into WebDynpro.

By the way, your approach to the Calendar-Date-conversion is rather error-prone and slower than necessary. I'd use setDate(new Date(cal.getTimeInMillis())) instead.

Regards

Nils

Former Member
0 Kudos

Hi Nils,

well, when you mapped the context attributes of your view to the same of the model, the data type of the attributes will be same as in the model. So if you need to convert the data type for view display purpose you have to create extra attributes in view, convert the recieved value attributes and bind the new value to the extra view context attributes. Thats how I think the approach is currently.

Regards,

Shubhadip