comments below...

> -----Original Message-----
> From: Jonathan [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 21, 2001 10:38 AM
> To: [EMAIL PROTECTED]
> Subject: Re: server-side, java-based validation rules for struts..
> 
> So at some point you will gat a handle to the ActionForm 
> (read "bean") and say:

Yes-- "you" in this case would actually be the Struts controller invoking
the digester, which in turn would instantiate our listener and then register
it with one of the methods below.

> actionForm.addVetoableChangeListener(String
> propertyName,VetoableChangeListener listener)
> or
> actionForm.addVetoableChangeListener(VetoableChangeListener listener)
> or
> the third one which I dont totally understand. (please explain  ;^> )

The third form allows a listener to be notified of any and all
VetoableChange events. Eg. Its not tied to any particular property on our
ActionForm, but it can issue Vetos. A proposed syntax for struts-config
could then be:

<form-beans>
  <form-bean name="MyForm" type="com.myco.MyForm">
    <change-listeners>
      <change-listener type="com.myco.MyFormValidator"/>
      <change-listener property="somePropertyName" 
                       type="com.myco.SomePropertyValidator"/>
    </change-listeners>
  </form-bean>
</form-beans>


> Also, please explain what the propertyName represents

propertyName is simply shorthand for reffering to the name of a bean
property.  eg propertyName = field name = member variable name = etc.

> 
> The best thing about this is that the associations between 
> beans and their listeners is don all in one place 
> (the xml file in our case). If you want to add listeners to
> a bean just add them to the file.

Correct-- For the really adventurous, you could take this a step further and
explore using IBM's Bean Markup Language for defining your ActionForms. 

@see http://www.alphaworks.ibm.com/tech/bml

> One thing I may suggest is that maybe you dont need to be 
> explicit with the type of listeners, and just register 
> listeners.  I 'm not sure, however, because I have not
> thought about the consequences of that yet.

I guess I didn't quite follow this last point.

-- Levi

Reply via email to