Implementing Custom Extension Buttons in NC65 UAP Environment

Defining the Action Class

Create a new Java class that extends nc.ui.uif2.NCAction. This class will contain the logic for your custom button. Ensure you have references to the model and editor components to interact with the UI state.

package nc.ui.yrdmd.yrdsellorder.plugin.action;

import java.awt.event.ActionEvent;

import nc.ui.pub.beans.MessageDialog;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.UIState;
import nc.ui.uif2.model.BillManageModel;

public class CustomProcessAction extends NCAction {

    private BillForm billView;
    private BillManageModel dataModel;

    public CustomProcessAction() {
        super.setBtnName("Execute Custom Logic");
    }

    @Override
    public void doAction(ActionEvent e) throws Exception {
        // Show a confirmation dialog to the user
        int confirm = MessageDialog.showOkCancelDlg(billView, "Confirmation", "Do you want to proceed with this action?");
        
        // Display the result of the user's choice
        String resultMsg = (confirm == MessageDialog.ID_OK) ? "Confirmed" : "Cancelled";
        MessageDialog.showHintDlg(billView, "Result", resultMsg);
    }

    public BillForm getBillView() {
        return this.billView;
    }

    public BillManageModel getDataModel() {
        return this.dataModel;
    }

    public void setBillView(BillForm billView) {
        this.billView = billView;
    }

    public void setDataModel(BillManageModel dataModel) {
        this.dataModel = dataModel;
        // Register the action as an app event listener
        dataModel.addAppEventListener(this);
    }

    @Override
    protected boolean isActionEnable() {
        // Enable the button only when the UI is not in edit mode
        return this.dataModel.getUiState() == UIState.NOT_EDIT;
    }
}

Configuring the Spring XML

Configure the action bean in the module's extension XML file. You must define the action and insert it into the appropriate container relative to existing actions. The code property is mandatory for the node to load correctly.


<beans>

    
    <bean id="visualSeparator" class="nc.funcnode.ui.action.SeparatorAction" />

    
    <bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
        <property name="actionContainer" ref="container" />
        <property name="actionType" value="notedit" />
        <property name="target" ref="pFApproveStatusInfoAction" />
        <property name="pos" value="after" />
        <property name="action" ref="visualSeparator" />
    </bean>

    
    <bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
        <property name="actionContainer" ref="container" />
        <property name="actionType" value="notedit" />
        <property name="target" ref="visualSeparator" />
        <property name="pos" value="after" />
        <property name="action" ref="customProcessBtn" />
    </bean>

    
    <bean id="customProcessBtn" class="nc.ui.yrdmd.yrdsellorder.plugin.action.CustomProcessAction">
        
        <property name="dataModel" ref="bmModel" />
        <property name="billView" ref="billForm" />
        
        <property name="code" value="custom_action_trigger" />
    </bean>

</beans>

Validating the Configuration

After creating the XML configuration, verify its syntax to prevent runtime errors. In an Eclipse environment, right-click the XML file and select the option to generate Java code or validate the Spring beans (often labeled SpringxmlToJava or similar depending on plugins). Successful generation indicates the XML structure is valid and references are resolvable within the project context.

Tags: NC65 UAP65 java Spring Enterprise Software

Posted on Thu, 18 Jun 2026 17:21:51 +0000 by airric