Invoke Save button after Report print

Can I save editor values and keep open it?

I will try to explain. I have a Print button inside editor screen and when pressed, a report is launched (myButton.setAction(new EditorPrintFormAction("report", this, null))).

1st: How to change a value in this editor (Status: Printed) once the button action is invoked.
2nd: How to save it, and keep editor open. Mainly my goal is to simulate windowactions Save button after the report is launched.

Hey,
I believe u can extend EditorPrintFormAction and add your logic in action perform then(or before) just call super.actionPerform(Component)

2 Likes

Hi,

Here’s an example of the approach suggested above:

public class ReportEntityEdit extends AbstractEditor<ReportEntity> {

    @Inject
    private Button button;

    @Override
    public void init(Map<String, Object> params) {
        button.setAction(new MyReportAction("report", this, null));
    }

    private class MyReportAction extends EditorPrintFormAction {
        
        public MyReportAction(String id, Editor editor, @Nullable String reportOutputName) {
            super(id, editor, reportOutputName);
        }

        @Override
        public void actionPerform(Component component) {
            getItem().setStatus(com.company.demo.entity.Status.PRINTED);
            getDsContext().commit();
            super.actionPerform(component);
        }
    }
}
1 Like

Olga, i just browsed EditorPrintFormAction - is it possible to make editor field protected or at least create getter?
I believe it can be really useful if developer need to have universal (across application) extended print action.

Ivan, we will consider your idea.

1 Like

@baranukis, @shiryaeva thanks to both for your aproach. Works perfectly.