cancel
Showing results for 
Search instead for 
Did you mean: 

How to add field length constraints when using an existing JavaBean model

Former Member
0 Kudos

Within our current project we used a O/R mapping tool to generate our JavaBean model. For e.g.

<b>public class Person{

private String name; ...getName() ...setName(...)

}</b>

The whole model is used within our Web Dynpro project. Now it's a requirement to implement field length constraints. Normally this is no problem using ISimpleType like the following:

<b>attributeInfo = wdContext.nodePerson().getNodeInfo().getAttribute

(IPrivate...IPersonElement.NAME);

ISimpleTypeModifiable type = attributeInfo.getModifiableSimpleType();

type.setLength(60);</b>

But we've got an runtime exception that it is not allowed to modify the models datatype:

com.sap.tc.webdynpro.progmodel.context.ContextException: AttributeInfo

<b>(Basics.Person.name): must not modify the datatype of a mapped attribute</b>

at

com.sap.tc.webdynpro.progmodel.context.AttributeInfo.getModifiableSimpleType

(AttributeInfo.java:337)

The question is how could a workaround look like. Or is there nothing like that and we have to build a dictionary type tier upon our JavaBean model. Any ideas ?

thx,

s.w.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Sabine,

You may:

1. Import JavaBeans model

2. Create DDIC type with necessary constarints (string-based, max. length 60)

3. Open editor for target model class and change type of property.

See my blog /people/valery.silaev/blog/2005/06/29/apojo--almostplain-old-java-objects-as-model (section "Tweaking model classes") for details.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com