Sean Legassick wrote:
> Leandro,
>
> That sounds very interesting, but I recommend you take a look at
> "intake" that John McNally has been working on (it can be found in
> conf/intake). It does a very similar job.
>
> Sean
Ok.... I realized that intake is focused on field ( input) validation. I forgot to
mention
that
this service I am trying to develop has a SecurityCheck Class which can be extended to
make any security check you'd like to do.
Let me describe it's intended use :
1 - We have a screen which display a form to the user. What I want, and if you have
anything
to add here, please ,
is to have my form validated for further processing, and if not, redisplayed with the
posted
information.
So ... our screen should look something like this :
doBuildTemplate(RunData data,Context context)
{
if("myForm.action".equals(data.getAction()))
{
form = (Form)context.get("form");
fields = (Field[])context.get("fields"); //DataFields
data.setMessage("MyForm has errors");
}
else
{
form =
((FormBrokerService)TurbineServices.getInstance().getService("FormBrokerService")).getForm(formToLoad);
fields = form.getFields(); // SchemaFields
data.setMessage("Fill the form please");
}
}
I designed this so it can read a form schema from a file described in TR.properties,
and
cache the form if we want to.
OBS : There is and important notice here : We have two types of fields. SchemaFields,
which
hold information like RE accepted by the field, name, etc.
and DataFields, which contain posted information by the user. This ditiction is
important
because of cache behavior : we must cache only the things that don't
change about this form.SchemaFields don't change, DataFields do.
So... we get a form ref ( cached or not according to TR.props), get it's fields, and
put then
in the context, so the Template designer can access then.
2 - After the Submittion, we must validate our Form . The validation proccess has two
fases,
first syntax then semantic validation.
Syntax validation occur comparing posted data against regular expressions described in
MyForm.xml (schema)
Semactics validation occur using extended SecurityCheck's in an Array. These classes
provided
extra information ( error messages, etc ) to the user.
This way whe can perform password validation, such as when we have two fields that
must have
the same value.
Our action show be something like this :
doPerform(RunData data,Context context)
{
SecurityCheck pwdCheck = new PasswordSecurityCheck(data); // extends
SecurityCheck
if(validateForm(data,context,new SecurityCheck[] {pwdCheck}))
{
// DO what you want
}
}
3 - If the form wasn't valid , validateForm() would have put in the context references
like
form, fields, and semantic error messages.
If the form is ok...... then... ok.. what can I say......
Ok.... I think thats it....... I you somebody interested. I would like to make a
contribution.
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]