Bug 768

Summary: Failed to load update coupon page in the admin panel
Product: CS3343 Salon Booking System Reporter: shukhyiu2-c
Component: admin.coupons.UpdateAssignee: kwanng9 <kwanng9-c>
Status: RESOLVED FIXED    
Severity: major CC: chtsang246-c, samuelip4-c, shukhyiu2-c
Priority: ---    
Version: 2.0   
Hardware: PC   
OS: Mac OS   
Attachments: UI of update coupon page
Screenshot for prove of problem solved

Description shukhyiu2-c 2023-11-04 18:40:59 HKT
Created attachment 145 [details]
UI of update coupon page

Description: 
Overview: 
When trying to update a coupon in the admin panel, coupon information and input fields are not shown on UI.

Steps to Reproduce: 
1. login as admin
2. select "Manage Coupons"
3. click a existing coupon in the list

Actual Results: 
The UI does not show the original information and input fields of the selected coupon The UI can be seen in the attached screenshot (Attachment: admin_coupons_Update_202311041830.png). Also, the following error is shown in the console:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at admin.coupons.Update.<init>(Update.java:67)
	at admin.coupons.Read$3.mouseClicked(Read.java:81)
	at java.desktop/java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:278)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6629)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
	at java.desktop/java.awt.Component.processEvent(Component.java:6391)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4584)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Expected Results: 
The system should show the original information and input fields of the selected coupon.

Build Date & Hardware: 
Build 2023-11-04 on Mac OS 13.1
Comment 1 chtsang246-c 2023-11-07 10:26:05 HKT
Already fixed in the latest version of the code. The issue was caused by the wrong parameter passed to the Update method in the Read.java file in admin.coupons package.
The code was revised as follows:
MouseAdapter mouseAdapter = new MouseAdapter() 
{
    @Override
    public void mouseClicked(MouseEvent e) 
    {
        int row = table.getTable().getSelectedRow();
        frame.get().dispose();
        new Update(tableDataRaw.get(row).split(", ")[0], tableDataRaw.get(row));
    }
};
Comment 2 Samuel 2023-11-17 12:23:25 HKT
Created attachment 150 [details]
Screenshot for prove of problem solved

Here is the testing result after correcting the problematic SQL query sentence