10 August 2009

numberSeqFormHandler

if you need to use a numberSequence in a form you can use the numberSeqFormHandler. Therefor you have to add a new method to the form an overwrite some methods of the datasource, as mentioned below. 1. Add in ClassDeclaration
NumberSeqFormHandler numberSequence; 
2. Add a new method for the numberSeqFormHandler on the form
NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSequence)
    {
        numberSequence = numberSeqFormHandler::newForm(
            NumberSequenceReference::find(
                typeId2extendedTypeId(typeID(__EDT_NumSeqId__))).NumberSequence,
            element, __Table_DS,
            fieldNum(__Table__, __NumSeqId__));
    }
    
    return numberSequence;
}
3. Override the datasource method create() / delete() / write() / validateWrite()
public void create(boolean _append = false)
{
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate();
}

public void write()
{
    ttsbegin;
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();
    ttscommit;
}

public boolean validateWrite()
{
    boolean ret;
    ;
    ret = super();
    ret = ret && element.numberSeqFormHandler().formMethodDataSourceValidateWrite();
    return ret;
}

public void delete()
{
    ttsbegin;
    element.numberSeq().formMethodDataSourceDelete();
    super();
    ttscommit;
}

public void linkActive()
{
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();
}
And remeber that continuous number sequences can only be used in transactions (between ttsbegin; and ttscommit;)
Post a Comment