beehive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlin Rogers <>
Subject Re: Jpf.Validating a string is within a Collection<String>
Date Mon, 13 Jun 2005 17:04:52 GMT
Hi Adam,

Two possibilities...

1) You could use a custom rule for this validation. Beehive NetUI supports
your own extensions to the validator framework. You might create a method.
in your page flow controller class or another class that has access to the
desired collection, checks that the platform submitted is in the collection.

As in Struts, the validation method you create has the following signature
    public static boolean validatePlatform( 
            Java.lang.Object bean, 
            org.apache.commons.validator.ValidatorAction va,
            org.apache.commons.validator.Field field, 
            org.apache.struts.action.ActionMessages errors,
            javax.servlet.http.HttpServletRequest request,
            javax.servlet.ServletContext servletContext )

Make sure that this method is thread safe. Then the next step is to
create a validation rule for your new method following the validator DTD.
The rule can be in your own file, WEB-INF/validation-rules-custom.xml
Something like...

      <validator name="customRulePlatform"
                       javax.servlet.ServletContext" >

Now you can use the customValidatorConfigs property on your
Controller annotation to provide the path to this custom validation rule
xml file. For the JPF ValidatableProperty annotations you can then
use the validateCustomRules property.

The Netui tests (coreWeb DRT) in the src repository covers this and
you might look at it as an example of the annotations.

2) Also, you could have your form bean implement a page flow interface,
org.apache.beehive.netui.pageflow.Validatable, and the validate() method. 
This could import your static method to get your collection.

Hope this helps,

On 6/13/05, Adam Jenkins <> wrote:
> Hi All,
> Can anyone offer advice on how I would validate that a value on the
> incoming form is contained within a collection?
> I have a static method imported to called
> getApplicationContext() which gives back a variable of type
> ApplicationContext.  This context object contains a bunch of application
> configuration information.  One of the methods on it is
> getSupportedPlatforms() which gives back a Collection<String> of
> supported database platform names.  This is used in a <netui:select> to
> populate the options, which works fine, but to ensure that someone
> doesn't try to circumvent the system, I want to put a validation on the
> actual form method that executes something like:
> getApplicationContext().getSupportedPlatforms().contains(actionForm.platform)
> Is there any way to do this?
> Cheers
> Adam

View raw message