How to achieve New/Delete Button functionality in SWT (Sage Web Toolkit)

By | January 20, 2012

As per the available resource of SWT workshop you can easily create a Form with label, Text box etc. But suppose we need the functionality to add new/delete button in a form, in this case refer the below code to achieve the functionality.
Below shown is the state code form, the objects used in Navigation, Load button and Save are the ones which we are aware of but apart from this we have added 2 extra buttons i.e. New button and Delete button.
The below XML code shows the snippet of code which adds the New Button within the screen. You can add the button either by using this xml code given below OR by using SWT UI Editor:
<widget type=”swt:SwtButton” id=”insertButton” hAlignInParent=”Default” vAlignInParent=”Top” datasourceID=”” preferencestoreID=”” helpID=”” height=”26″ width=”50″ accessKey=” “>
<transText text=”” textID=””/>
<caption isHTML=”false”>
<transText text=”New” textID=””/>
<handler event=”click” action=”insert”>
<param id=”datasourceID” value=”dtstatecode”/>
Below given are list of Actions and their description with the required parameters for click event, which are used for Insertion and Deletion of the records.
The actions mentioned in the above table is used as per requirement
Action for Saving New Record:  If we want to insert the new data into the table then we can use combination of two actions “moveToInsert” and then “Save” action OR  using only “insert” action.
Action for Delete Entry:  If we want to delete entry from table we can use delete action. We can use the “deletePrompt” OR “deleteEntityPrompt” actions to prompt a warning before delete action are executed.