Adding a Save Button and Saving Data

Procedure

  1. In the UI Modeler , in the context menu of OrderCompView , Choose Start of the navigation pathTemplate Next navigation step Apply...End of the navigation path
  2. Select the Action Button template and choose Next .
  3. For Button Label , enter Save and choose Finish .

    The new button is added to the view layout.

  4. Save your changes.
  5. Select the Save button and inspect its properties.
  6. In the Properties pane, for the text property, enter the value Save .
  7. In the Properties pane, in the onAction row click Save .

    The buttons Go and Create appear.

  8. Choose Go .

    The Java editor opens. The section of code that you need to edit is highlighted.

  9. In the code of the onActionSave() method, enter code to save all dirty changes, re-execute the query, and reload the item node to reflect the change in the item table. The completed code should be the same as the example below (you can copy the example into the editor):

    /**

    * Event handler [onActionSave].

    */

    public void onActionSave (Event wdEvent) {

    //@@begin onActionSave(ServerEvent)

    OcaRoot. getInstance ().commit();

    wdContext.nodeorder_srv().nodegetItemsByOrderId().nodegetItemsByOrderIdOutput().reload();

    //@@end

    }

  10. Save your work and build the component.