In a screen file containing the velocity code below :-
#set ( $departmentGroup = $intake.Department.Default )
#if ( !$departmentGroup.RowID.isValid() )
$departmentGroup.RowID.Message<br>
#end
Dept. ID <input name= "$departmentGroup.RowID.Key"
value="$!departmentGroup.RowID" size="25" type="text">
the value $departmentGroup.RowID.Message is always blank.
$departmentGroup.RowID.getValidator() does not work, it only
returns the string "$departmentGroup.RowID.getValidator". I
tried this when testing to see if $departmentGroup.RowID was
a Field object.
I've tried the screen with different values that fail / pass the rules
determining validity and output pass / fail to turbine.log. I'm
certain my validation rules are correct but I can't figure out
how to get the messages on validation pertaining to the rule
being violated from the project-inputs.xml file.
Here's the group in project-inputs.xml (TurbineProperties
knows about this file and Intake is parsing it with no problems)
<input-data basePackage="com.softghana.pettycash">
<group name="Department" key="department" mapToObject="om.Department">
<field name="RowID" key="rowid" type="NumberKey">
<rule name="mask" value="^$|[0-9]+">Invalid Object ID. Call
SOFT.</rule>
<rule name="required" value="true">Invalid Object ID. Call
SOFT.</rule>
<required-message>Object ID must either be a number or
blank.</required-message>
</field>
<field name="Name" key="name" type="String">
<rule name="minLength" value="1">Please enter a department
name.</rule>
<rule name="maxLength" value="50">Department name cannot be longer
than 50 characters</rule>
<rule name="required" value="true">A department name is
required.</rule>
<required-message>You need to give a name to this
department.</required-message>
</field>
</group>
</input-data>
I tried creating rules like
<rule name="required" value="true">Message when required</rule>
tried changing
<field name="RowID" key="rowid" type="NumberKey">
to
<field name="RowID" key="rowid" type="NumberKey"
validator="NumberKeyValidator">
after looking at the intake code but to no avail.
XmltoAppData.java shows that the messages are being parsed ok as below:-
public void characters(char[] mesgArray, int start, int length)
{
String cdata = new String(mesgArray, start, length).trim();
if ( "rule".equals(currElement) && cdata.length() > 0)
{
currRule.setMessage(cdata);
}
if ( "required-message".equals(currElement) && cdata.length() > 0)
{
currField.setIfRequiredMessage(cdata);
}
}
now fields get flagged as valid / invalid by their assigned validator inside
the
Field.validate(ParameterParser pp) method
try
{
validator.assertValidity(s);
}
catch (ValidationException ve)
{
setMessage(ve.getMessage());
}
So how does one go about showing messages when input data violates the
constraints
specified in project-input.xml ? Everything seems fine - I must be missing
something.
Also what's the difference between <required-message></required-message> and
<rule name="required" value="true"></rule> ?
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]