/** * The simplest constructor. The action uses default name and other parameters. * @param table table containing this action */ public ExcelAction(Table table) { this(table, AppConfig.createExportDisplay(table.getFrame()), ACTION_ID); }
protected void callControllerInvoke(Entity rowItem, String columnId, String invokeMethodName) { FrameOwner controller = table.getFrame().getFrameOwner(); Method method; method = findLinkInvokeMethod(controller.getClass(), invokeMethodName); if (method != null) { try { method.invoke(controller, rowItem, columnId); } catch (Exception e) { throw new RuntimeException("Unable to cal linkInvoke method for table column", e); } } else { try { method = controller.getClass().getMethod(invokeMethodName); try { method.invoke(controller); } catch (Exception e1) { throw new RuntimeException("Unable to call linkInvoke method for table column", e1); } } catch (NoSuchMethodException e1) { throw new IllegalStateException(String.format("No suitable methods named %s for invoke", invokeMethodName)); } } }
@Override public Component generateCell(Entity entity) { if (unableToFindMethod) { return null; } Frame frame = table.getFrame(); if (frame == null) { throw new IllegalStateException("Table should be attached to frame"); } FrameOwner controller = frame.getFrameOwner(); if (method == null) { method = findGeneratorMethod(controller.getClass(), methodName); if (method == null) { this.unableToFindMethod = true; String tableId = table.getId() == null ? "" : table.getId(); throw new IllegalStateException( String.format("No suitable method named %s for column generator of table %s", methodName, tableId)); } } try { return (Component) method.invoke(controller, entity); } catch (Exception e) { throw new RuntimeException("Exception in declarative Table column generator " + methodName, e); } }