openxava

How to make an Entity updatable but not insertable or deletable in OpenXava?


What if some entities should'n be deletable or insertable? Is there an easy way to get rid of the "new" button and trash can icon?


Solution

  • If you're using XavaPro just remove the access to the new and delete actions for the role. Otherwise, you should create a controller with just the save action and define a module using it.

    That is, in controllers.xml add:

    <controller name="OnlySave">
    
        <action name="save" mode="detail"
            by-default="if-possible"
            class="org.openxava.actions.SaveAction"
            image="save.gif"
            icon="content-save"
            keystroke="Control S"/> 
                            
    </controller>
    

    And in application.xml define a module for your entity in this way:

    <module name="Customer">
        <model name="Customer"/>
        <controller name="OnlySave"/>
        <controller name="Print"/>                                        
    </module>