cancel
Showing results for 
Search instead for 
Did you mean: 

validation of context attributes with adaptive webservice model

Former Member
0 Kudos

Hi, I am creating a Web Dynpro Java application (on top of Netweaver AS 7.0) using an adaptive webservice model to invoke a webservice.

The webservice has some request attributes of type string with limited length (for example limited to 1 character). I bound the model to component controller context and created a mapping between the component controller context and view context. In the view, I created a form which is bound to the context attributes.

When user enters string values, which are longer than the maximum length specified in webservice WSDL, and submits the form, an exception is thrown when Web Dynpro runtime is trying to assign entered values into context attributes:


com.sap.dictionary.runtime.DdCheckException: Length of character string "abcdef" must be smaller than or same as MaxLength 1;

    at com.sap.dictionary.runtime.DdTypeString.checkValid(DdTypeString.java:195)
    at com.sap.tc.webdynpro.model.webservice.base.model.BaseGenericModelClass.setAttributeValue(BaseGenericModelClass.java:304)
    at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClass.setAttributeValue(WSTypedModelClass.java:62)
    at at.gov.bmf.demo.comp.employee.model.OrganizationalAssignment.setEmployeeGroup(OrganizationalAssignment.java:52)
    at at.gov.bmf.demo.comp.employee.wdp.IPublicEmployeeDemo$IOrganizationalAssignmentElement.wdSetObject(IPublicEmployeeDemo.java:1552)
    ... 32 more

This exception is thrown before my non-validating action is executed, so I am not able to prevent it or handle it.

Is there any way how to catch this exception or prevent it?

Does anyone know where these model restrictions are stored? I searched the XML files generated for the model, but I haven't found anything. Does the Web Dynpro runtime access WSDL everytime it needs to validate request parameters?

Thanks,

Tomas

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

Try this

1.Create One SimpleType --Open the editor

2.Under Definition define the maximum length in your case its 1.

3. Cratate One context attribute say validation.

4Bind this context to Simple type created in step1

5.Bind this attribute to UI where u want validation

Best Regards

Satish Kumar

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Satish,

what is that model driven solution you mention?

Regards,

Tomas

former_member185086
Active Contributor
0 Kudos

Hi

WebDynpro provides us a better model driven solution in our problem context, what I mean is Just It require a defining a simple-type least worrying about how it handle internally.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi,

the webservice is exposed from ABAP, but it is not RFC, it is real webservice.

Regards,

Tomas

Former Member
0 Kudos

Hi Satish,

thank you, this way user is not able to enter more characters than supported by the field.

However, this way I have to manually create a context structure and then map values from this structure to the one bound to model.. which can require a lot of work if the webservice has lots of parameters.. Is there any way how to use only the context attributes bound to model?

Regards,

Tomas

Former Member
0 Kudos

Hi

is the webservice exposed from the Java or EJB . or have you used a RFC .

former_member185086
Active Contributor
0 Kudos

No ,This is the preferred and safer way to separate the Model Node and and Input Node and relationship between them by using mapping.

You create your context structure for input and then on action set user input to model data.

Safer it means : Sometimes it happen that model data not populated properly due to network or wrong user input etc ,this time our presentation will be safe and display the proper error message rather the screen went away with null pointer exception.

Regarding your - it require a lot of work. It too much convince for us that rather than writing 50 lines of code

for only input length validation WebDynpro provides us a better model driven solution.

Best Regards

Satish Kumar