cancel
Showing results for 
Search instead for 
Did you mean: 

NumberFormatException - handle text in number metadata? ...

csiege
Champ in-the-making
Champ in-the-making
I have a custom content model type defined with a property of type int.  When a user enters some text into that field and clicks ok, the webclient gives a VERY nasty error message and the log file records the NumberFormatException error.

The biggest problem is that the error message doesn't give the user any indication that they simple entered a text value into what was expected to be a number.

Is there a mechanism for handling this?

As always, thanks for the help!

Chris
5 REPLIES 5

gavinc
Champ in-the-making
Champ in-the-making
What version are you using?

We added support for constraints in 1.3 which the property sheet handles. You could use the NumericRange constraint on the property or write your own custom constraint.

However, I agree, this is a bug, the property sheet should deal with that scenario in a graceful manner.

csiege
Champ in-the-making
Champ in-the-making
Do you have an example of how to use NumericRange?

thanks!

Chris

csiege
Champ in-the-making
Champ in-the-making
ok, I got this working… BUT

Is there something I am missing here?  Is there some hidden documentation around to explain this stuff…  the only way I could find out how to get this working was going through the source code…  and even with that I feel a little lucky…

gavinc
Champ in-the-making
Champ in-the-making
I think this is an undocumented feature!!

By the way, I raised an issue regarding your original problem, if you want to track its progress: http://www.alfresco.org/jira/browse/AWC-777

csiege
Champ in-the-making
Champ in-the-making
To get an example out here on the forum here is what I found 🙂

     <property name="myLNB:labNotebookNum">
               <title>LNB Number (number only)</title>
               <type>d:int</type>
               <constraints>
                              <constraint type="MINMAX">
                                    <parameter name="minValue"><value>5</value></parameter>
                                    <parameter name="maxValue"><value>10</value></parameter>
                             </constraint>
              </constraints>
       </property>



also an example I found in JIRA that looked useful…

<constraints>
      <constraint name="cm:myconstraint">
         <min>0</min>
         <max>255</max>
         <regex>[a-z]*</regex>
         <length>100</length>
         <list>
            <value>0</value>
            <value>1</value>
            <value>2</value>
         </list>
      </constraint>
   </constraints>
   
   <types>
   
      <type name="cm:cmobject">
         <title>Object</title>
         <parent>sys:base</parent>
         <properties>
            <property name="cm:name">
               <title>Name</title>
               <type>d:text</type>
               <mandatory>true</mandatory>
               <constraints>
                  <constraint ref="cm:myconstraint" />
                  <constraint>
                     <regex>[A-Z]*</regex>
                  </constraint>
               </constraints>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>cm:auditable</aspect>
         </mandatory-aspects>
      </type>
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.