ResetAfter for SaveAndStayElementInCollectionAction

Help
2013-06-06
2013-06-17
  • Hi,
    is the resetAfter flag available when inserting new items in a collection?
    If no, can someone give me a hint on how can i implement that.
    Thx,
    Fred.

     
  • Javier Paniza
    Javier Paniza
    2013-06-10

    Hi Frederico,

    is the resetAfter flag available when inserting new items in a collection?

    No. You should use @SaveAction to define your own action logic, maybe refining the default one.
    If it would be a common case we could add this behavior by default, so I ask you:
    why don't you want to clear the data after save the collection element?


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • I explayned the situation in the other thread and forgot to mention,sorry.
    Change color of Label or Field in SaveAction:
    "Im writing an application where, after saving a collection, i connect to a REST service, pass the properties and check if the user needs to fill another field.
    Everything is ok, but i want to signal to the user which fields he should fill (change color of the label, put a image next to the label"

     
  • Javier Paniza
    Javier Paniza
    2013-06-12

    Hi Frederico,

    pass the properties and check if the user needs to fill another field.

    In that case add some message using addError() from your action and the view will not be reset.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • Nice trick, but it didnt work, the collection is still being saved. What am i doing wrong?
    I extended SaveAndStayElementInCollectionAction and overrided the execute() method.
    My code:
    public void execute(){
    ...
    addError(...);
    super.execute();
    }
    Thx again,
    Fred.

     
    Last edit: Frederico Oliveira 2013-06-12
  • Javier Paniza
    Javier Paniza
    2013-06-14

    Hi Frederico,

    adding an error prevent the hiding of the dialog, but not stop the execution flow or rollback the transaction, that is your business, so write:

    if ( ... ) {
       addError( ... );
       return;
    }
    super.execute();
    

    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • I tryed that too, but it was still saving. I think its because SaveAndStayElementInCollectionAction implementes IChainAction.
    What I've done was change the method getNextAction by this:

    public String getNextAction() throws Exception {
    if (getErrors().isEmpty()) {
    return (getCollectionElementView().getSaveCollectionElementAction());
    } else {
    return null;
    }
    }

    Its working now.

     
  • Javier Paniza
    Javier Paniza
    2013-06-17

    Hi Frederico,

    Uhhm! I think you're extending the incorrect action. You have to extend SaveElementInCollectionAction and define it in the @SaveAction. This action is not a chained action. You don't need to overwrite SaveAndStayElementInCollectionAction, indeed does not exist a way to overwrite it.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.