> I've never noticed this before... but I am only just migrating to TDK 2.2b3 
> now.  If you provide small snippets of the relevant section of your action 
> and screen/template code, I could have a look to see if you are doing 
> anything out of the ordinary.
> 
> -- Rodney
> 

Essentially I have the following in the intake.xml:

<group name="ForwardAdd" key="mforwardadd">
   <field name="Add" key="add" type="String">
     <rule name="maxLength" value="255">TEXT.std_field_long_error</rule>
     <rule name="mask" 
value="^.+@[A-Za-z0-9\-]+\.[A-Za-z0-9\-\.]+$">TEXT.illegal_email_address</rule>
   </field>
</group>

The group and field are pretty standard.  I have the following in the 
velocity template:

#set ($fagroup = $intake.ForwardAdd.Default)

... later on ...

Add an email address:
<input type="text" name="$fagroup.Add.Key"
value="$!vcstr_tool.toHtml($!fagroup.Add.Value.toString())" size="25">
<input type="submit" name="eventSubmit_doAddforward"
value="Add">

<!-- This is the error message -->
<font size="1">
#if (!$fagroup.Add.isValid())
$!vcstr_tool.toHtml($i18n.get($fagroup.Add.Message))<br>
#end
</font>

The vcstr_tool is my custom thing that'll escape the html characters 
from the given string.

In the handler code (an action):

     public void doAddforward(RunData data, Context ctx)
     {
         IntakeTool intake = (IntakeTool)ctx.get("intake");
         if (intake.isAllValid())
         {
             try
             {
                 Group forwardAdd = intake.get("ForwardAdd", 
IntakeTool.DEFAULT_KEY);
                 Field addField = forwardAdd.get("Add");
                 .... more stuff to use the addField here ...
             }
             catch (Exception e)
             {
             }
         }
         else
         {
             data.setMessage(
                     Localization.getString("TEXT.Invalid_input", 
data.getRequest()));
             return;
         }
     }


The problem is, if I put in a wrong value (that violates the regex, for 
example) in the text box, the wrong value will disappear the next time 
when I load the page, even though the correct error message is displayed.

When I stepped through the debugger I found that the value is gone 
before the "IntakeTool intake = ..." line.  I even traced to the init() 
call of the IntakeTool and it seems like the value is gone after you 
call init() of the tool.  Is there anything I do wrong here?

On the side note, I have always had issue with Intake's handling of 
empty strings.  What I realize is, if you have an empty string in the 
form, it won't get submitted (or the ParameterParser won't take it??  I 
didn't do much investigation on this).  As a result, the field 
associated with the empty string will not appear in the group.  However, 
sometimes I REALLY want to have a field that sets to null or "".   If I 
use the mapToObject to map a certain field to an object, calling 
setProperties() will not call "set" for the empty fields.  Thus, the 
internal state of the object would not change.  Is there anything I can 
do here?

-- 
William Lee (Will)        | Sendmail Inc.
Email:  [EMAIL PROTECTED] | http://www.sendmail.com
Tel:    (510) 594-5505    |


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to