Button problems

Hello CUBA Support,
I searched the forum and could not find an answer for a problem I’m having. I just started using CUBA the other day. I created a test project similar to the 4 Quick start videos. I would like to make the Edit button on the Orders browse screen non-functional. In Properties I unchecked Enable. The messages indicated the hot deploy action occurred. But, the button remains clickable. I unchecked the Visible attribute. The button disappears in the GUI designer. When I run the app, the button is still visible and clickable. I’ve looked in the XML. Both attributes for the button are set to false. I’ve restarted the entire system, Studio, app server, launched the web app, and the Edit button still works and brings up the Orders edit view!

Why are my changes not taking effect?

BTW, I really like CUBA so far. I come from a Visual Studio / WinForms / C# background and this system seems to be closest for making web apps in the same way, maybe even better.

One other question: The Hot Deploy choice in Screens is missing. Was it removed since some of the videos?

I look forward to your reply,

Stephen

Hello Stephen,

From the documentation:
If an Action instance is defined for a Button, the button will take the following properties from it: caption, description, icon, enable, visible. caption and description properties will be imported from Action only if they are not set in the Button itself. All other listed Action properties have priority over the Button properties. If Action properties are changed after the Action is set for a Button, then Button properties also change accordingly, i.e. the button listens to the changes in Action properties. In this case, the caption and description properties will change even if they were initially assigned to the button itself.

So, in Studio in a screen designer, you can choose your table, open properties pane, click the edit button opposite actions property and disable the Edit action instead of a button. Or just move edit attribute from the Edit button to the Edit action in XML.

The Hot Deploy settings were moved to a special screen Help → Settings

Regards, Gleb

Hello Gleb,

Thank you for your reply. Sorry I didn’t check the documentation. But, it wasn’t as clear as your answer, so thank you.

I would now like to ask how I would enable and disable the action and button programmatically?

Thank you!

Stephen

Hello Stephen,

You need to inject your button or action and then call setEnabled(boolean) method. For example:


public class OrderBrowse extends AbstractLookup {
    @Inject
    private Button editBtn;
    
    @Named("ordersTable.edit")
    private EditAction ordersTableEdit;

    @Override
    public void init(Map<String, Object> params) {
        editBtn.setEnabled(false);
        ordersTableEdit.setEnabled(false);
    }
}

Regards, Gleb

Hello Gleb,

Thank you very much for your reply, it looks like this is exactly what I need! Question(s) answered!

Regards,
Stephen