I need to insert a value to the field table and I have a display method which returns this value Is there a way to assign a return value from display method to a table field or calling this display method in insert()?

Thanks

有帮助吗?

解决方案

From my experience, you can use display methods just as you do ordinary methods. So, to add the value of a display method as a value to a table (in the insert or initValue method) just state:

this.[FieldName] = this.[MethodName]();

If you are on a different object (IE, not a table), it may need to be accessed differently, but the concept is still the same.

其他提示

Although it's not a best practice, you can use the return value of a display method like any other methods. This said, the best practice is to not do it that way but create a getXXX method that get the value, and a display method that returns the new get method return value:

private Qty getQty() // it can be public if it's needed
{
    Qty q;
    ;

    // do stuff to get or calculate the return value

    return q;
}

display Qty displayQty() // displays are always public by default
{
    return this.getQty();
}

This way you can assign appropiate security to the display method whithout interfere the logic to get the value, and the get method will be reusable for displaying but also for other methods.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top