|
Hey all, I just committed a large change to validation. In the past
there was an ErrorManager that would read data from the ErrorMessages.xml.
There were a few problems with this: 1) Contextually,
it was specific to error messages. It was illogical to add other messages into
that document. 2) All data for
all objects was stored in one big file. 3) The ErrorMessage.xml
was only generated or updated when a record was. 4) More, but I’m
too lazy to get into it. I’ve added a new type of object, a Dictionary to
Reactor. You can now, if need be, call createDictionary(name) on the
reactorFactory. This will return a very simple reactor.dictionary.dictionary
object which has one method, getValue(). The dictionary object reads a dictionary xml file stored
under /yourDataMapping/Dictionary/yourObjectNamedictionary.xml. Each
dictionary XML file is created for one type of object and has a structure like
this: <dictionary> <teacherId> <label>teacherId</label> <comment/> <notProvided>The teacherId
field is required but was not provided.</notProvided> <invalidType>The teacherId
field does not contain valid data. This field must be a numeric
value.</invalidType> </teacherId> … (more nodes for each field) … </dictionary> The teacherId node represents one field. You can get
messages out of the dictionary with the Dictionary object’s getValue
method. For example: MyDictionary.getValue(“teacherId.label”) That will return the label text. MyDictionary.getValue(“teacherId.invalidType”) That will return the invalidType text. You can add as many messages in there as you want. I haven’t
tested it, but I’m pretty sure you can nest other messages, etc. For
example, this might work: <dictionary> <mymessage>Foobar</mymessage> <teacherId> <label>teacherId</label> <comment/> <notProvided>The teacherId
field is required but was not provided.</notProvided> <invalidType>The teacherId
field does not contain valid data. This field must be a numeric
value.</invalidType> </teacherId> … (more nodes for each field) … </dictionary> MyDictionary.getValue(“mymessage”) If you delete any one of the generated messages (for
example, teacherId.notProvided) it will be regenerated (when not in production
mode). I suggest keeping all your validation messages in your
Dictionary XML files. The label and comment messages can be used with something
like form generators. You can update your label to be human readable. You
could also add a comment and then just pass the record or dictionary into a custom
tag that generates a form field for you (or something). I’ve been
thinking about other messages that could be in here by default, but nothing
else comes to mind. To start using this get latest and delete your project
files. You’ll probably want to move your error messages into the new
dictionaries and to delete your old xml file. Doug |
- [Reactor For CF] Update to validation Doug Hughes
- Re: [Reactor For CF] Update to validation wikiwikiman
- Re: [Reactor For CF] Update to validation Clayton Partridge
- RE: [Reactor For CF] Update to validation Doug Hughes
- Re: [Reactor For CF] Update to validation wikiwikiman

