Create a Data Utility (Step 3)
Overview
What is different?
You are rendering a column in a table of changeables (ie. parts, documents) which represents a value on the binary link associating the changeable to the change object.
The value must be retained between:
Paging beyond the page limit
Sorting the table
Changing table views (which may not even display the column or the row!)
Survive additions and removals to the table.
The class ChangeLinkAttributeDataUtility has many helper methods and provides useful customization points to extend to assist with handling the above cases.
For performance, using the ChangeLinkAttributeDataUtility will cache the links for the method request so multiple attributes can be processed efficiently.
Process
The following are the key points that are required to make a working change link attribute data utility:
1. Extend the class ChangeLinkAttributeDataUtility.
2. Override the method createGuiComponent(String id,Object datum,ChangeLinkAttributeBean linkBean); The ChangeLinkAttributeBean is a specialized bean class to support managing the links in the request.
3. Use linkBean.getObjectReference(datum) to get the ObjectReference of the changeable from the datum (normalizes the reference type for the table).
4. Leverage getGUIComponentId(component_id, wtreference) to generate an id for the GuiComponent based on the following parameters:
component_id: Component id returned by the parameter id in the createGuiComponent method.
wtreference: Reference to the changeable object associated with the object type ChangeRecord2.
As an example, if the component id is distributionList, the getGUIComponentId method returns the value: VR:wt.part.WTPart:67429#distributionList.
5. Set the name and id of the GuiComponent to the generated value above.
6. For in-place editable fields, call super.setEventListener(component,linkBean); to setup a listener to copy the edited value onBlur for the component.
7. Override retrieveValue(String id, BinaryLinklink); to extract the attribute value from the link (for VIEW and initial EDIT component modes).
8. To get the current value use retrieveValue( )
9. Override ProcessExistingLinks(NmOid oid,String componentId) to load the links into the dataUtility.
10. Register the created custom data utility.
這是否有幫助?