mandag den 20. juli 2009

Indicating mandatory field in a dialog (RunBase) class.

A classical problem is indicating that a field is mandatory in a dialog, when the field is not bound to a datasource/field in a datasource.

Normally fellow developers will tell you that, that is not possible.

I found a way to do this.

In your Runbase-based class you can implement the putToDialog-method e.g like this:

protected void putToDialog()
{
super();
fieldMask.fieldControl().mandatory(true);
}


where fieldMask is a DialogField object in your dialog.


This will make the field act like it was a mandatory field from a datasource in a form, showing a red-wavy line under the field, and requiring the field to have a value.


Attention:

Your class has to run on the client.If you set your class to run on the server, you get a run-time error, when the fieldMask.FieldControl()-call is made.

1 kommentar:

  1. I've added my code as below:

    FormStringControl fsc;


    fsc = DlgFd.control();
    fsc.mandatory();

    It is giving red wavy on that field of the dialog but dialog is allowing us to OK with out the fields value.

    Can you please suggest me.

    thanks in advance.

    SvarSlet