Basic Customization > User Interface Customization > Presenting Information in the UI > Attribute Customization > Windchill Attribute Customization Overview > Common Attribute Customization Procedures > Limiting the Length of Values Entered for a String Attribute
  
Limiting the Length of Values Entered for a String Attribute
You want to limit the length of the value entered for a string attribute.
Solution Elements
Element
Description
upperLimit, lowerLimit Constraints
A constraint defined when defining the modeled class. See the information on PropertyConstraint in Modeling Business Objects for more information.
String length Constraint
A constraint defined in the Type and Attribute Management utility. See Attribute Constraint Rules for more information.
Character Entry Limit
The property Character Entry Limit can be set on a modeled, global or local attribute. See Configuration Points for more information.
Intended Outcome
You are able to restrict the length of string attributes in the UI and/or during persistence and provide feedback to the user when the limit is exceeded.
Solution
The combinations of the solution elements required to achieve the different kinds of behavior are listed below:
If you want to…..
Configuration
Restrict input to a certain number of characters on all the UIs in which the attribute will be displayed for editing.
Also apply this restriction during persistence. This applies when you want to create an object programmatically (without a UI) or, when some attributes of an object are not added to the Create UI of an attribute.
For modeled attributes, use upper limit, lower limit constraints.
For global and local attributes, use the String length constraint.
The string length constraint can be used on modeled attributes also to make configurations without requiring Java code compilation.
Limitation: The length of the Name attribute conforms to Windchill UI standards and so cannot be overridden using this constraint.
Restrict input to a certain number of characters on a specific UI only.
Also, do not apply this restriction during persistence.
Use the property Character Entry Limit.
Note: This limit has to be less than the maximum string length.
Byte length
The validation in the end-user UI also takes into consideration the number of bytes needed to store the characters entered, to account for variable width encoding and multi-byte databases.
Merging multiple constraint definitions
When the upperLimit, lowerLimit constraints are specified in the modeled class and one or more String length constraints are specified for the same attribute in the Type and Attribute Management utility, all these constraints are compiled together to provide a range that is common to all of them.
So the minimum number of characters that can be entered will be the maximum of all the lower limit values. The maximum number of characters that can be entered will be the minimum of all the lower limit values.
Example:
Annotated Constraint: Lower limit = 30 Upper limit = 50
Type and Attribute Management utility String Length constraint 1: 20 – 40
Type and Attribute Management utility String Length constraint 2: 35 - 45
Result of combining all these constraints: 35 - 40