1) Use pack/unpack on Form
If you have used runbase classes, you may be impressed by its pack and unpack mechanism. It allows users to keep the input values of last time. If you want to implement the same mechanism on the Form, it is easy as well:
Besides Pack/Unpack, add these six methods:
public class FormRun extends ObjectRun
{
...
#define.CurrentVersion(1)
#localmacro.CurrentList
values...
#endmacro
}
public container pack()
{
return [#CurrentVersion, #CurrentList];
}
public boolean unpack(container packedClass)
{
Integer version = conpeek(packedClass,1);
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
public dataAreaId lastValueDataAreaId()
{
return curExt();
}
private UserId lastValueUserId()
{
return curuserid();
}
{
return curuserid();
}
private UtilElementType lastValueType()
{
return UtilElementType::Form;
}
{
return UtilElementType::Form;
}
private IdentifierName lastValueElementName()
{
return this.name();
}
{
return this.name();
}
private IdentifierName lastValueDesignName()
{
return ”;
}
//this is called when no last value is retrieved
void initParmDefault()
{
}
further, in Close method of the form:
public void close()
{
super();
//add saveLast method after super()
xSysLastValue::saveLast(this);
}
in init method of the form:
public void init()
{
;
{
return ”;
}
//this is called when no last value is retrieved
void initParmDefault()
{
}
further, in Close method of the form:
public void close()
{
super();
//add saveLast method after super()
xSysLastValue::saveLast(this);
}
in init method of the form:
public void init()
{
;
//Add getLast method before super()
xSysLastValue::getLast(this);
super();
…
}
2)Container lastValues;xSysLastValue::getLast(this);
super();
…
}
get
lastValues = xSyslastValue::getValue(curext(), curUserId(), utilElementType::Form,element.name() + "out","");
put
xSyslastValue::putValue([JournalName],curext(), curUserId(), utilElementType::Form,element.name(),"");
没有评论:
发表评论