cancel
Showing results for 
Search instead for 
Did you mean: 

Maxlength in a InputField

Former Member
0 Kudos

hi everybody,

i want to put the maxlength attribute in a inputfield control, but i don´t see the property in the attribute window for this control.

Somebody knows.. how to do it or only this type of validation are by code?

thks

Josué

Message was edited by: Josue Cruz

Message was edited by: Josue Cruz

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In webdynpro explorer open the project structure. in dictionary->local dictionary->simpletypes

right click and create a simple type. You can set the various parameters like minimum length ,maximum length, basic type etc. if you en you create an attribute give the property type as the simple type you created

the validations will be done when you perform an action in the view

Regards

Rohit

Answers (2)

Answers (2)

Former Member
0 Kudos

Following your instruction on changing the type: my view context is map to a web services object and Web Dynpro would not allow me to change the type. Any thought?

Former Member
0 Kudos

Christian,

Then this is typical case for calculated attributes.

Say, you have model node MyWs_Request with model attribute MyParam of type string. You want to limit number of characters for MyParam attribute.

Create 1..1 non-singleton value sub-node MyWs_Request_Proxy as direct child of MyWs_Request node. In this node create attribute MyParam_Proxy with your custom simple type defined in Local Dictionary (sure, this custom type must have MaxLength restriction set). Make this attribute calculated and NW IDE will generate getter/setter methods. Fill in the following:

in getter:


final IWDNodeElement real = element.node().getParentElement();
return (String)real.getAttributeValue("MyParam");

in setter:


final IWDNodeElement real = element.node().getParentElement();
real.setAttributeValue("MyParam", value);

Now bind any InputFields to calculated proxy attribute. MaxLength restriction will be applied.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Josue,

To have the length limited in the browser you need to setup a simple type and set its maximum length to what you want. Then on the context attribute you have bound your input field to, set the type to the simple type you setup. When the html is generated it will include a maxlength tag for that input field and the browser will limit the entry to that number of characters.

Cindy