Skip to Content
author's profile photo Former Member
Former Member

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 10, 2005 at 04:04 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.