Set focus on the dialog field

1)Problem Statment:
Hi,

I have this requirement, i have a run base class with a dialog Field. i need
to validate the vaue in the field and i need to set focus on the field if the
value is not validated. The problem is dialogfield does not have setFocus
method.
Can any one help me out in this regards.

Solution :
As you right noticed really dialogfield doesn’t have setFocus. And not only

setFocus. Dialog was developed just for simple user input.
The better decision in this case is creating separate form where you may
override every control’s event and in a dialog method of your runBase class
call this form.
 
Take a look for example at \Classes\WMSShipmentShip and
> \Forms\SysProjectFilter.

If you eagerly wish set focus in dialog there is nothing impossible

// here we achieve myCtrl
public void dialogPostRun(DialogRunbase dialog)
{
    super(dialog);

    myCtrl =
dialog.dialogForm().formRun().control(dialogTransDate.control().id());
}

in method where you validate:
myCtrl.setFocus();

But I’d like to say again
the better solution is sepate form

2) on the report's Dialog field

public boolean  getFromDialog()
{
;
    g_FromDate          = dlg_DialogField1.value();
    g_ToDate            = dlg_DialogField2.value();
    g_VendAccount1      = dlg_DialogField3.value();
    g_VendAccount2      = dlg_DialogField4.value();
    isRank              = dlgisRank.value();
    g_ItemBuyerGroupId  = dlg_DialogField7.value();
    g_RankPosition      = dlg_DialogField8.value();
    if(isRank && g_RankPosition == 0)
    {
        //DialogRunbase   dialog; //global variable
        dialog.dialogForm().formRun().control(dlg_DialogField8.control().id()).setFocus();
        //setFocus for the dlg_DialogField8
        throw Error("Please enter number of records for vendor ranking");
    }
    return true;
}

posted @ 2010-12-02 09:24  Fandy Xie  Views(664)  Comments(0Edit  收藏  举报