onSave="save,new"

Hi, i try to implement pattern save & new. documentation suggest the « new » action keyword.
I had tried with the onSave=« save,new »
I can’t manage to make it work.
Any suggestion ?

You can use groovy script action to implement it

Hi, any example ?
from what I understand, groovy scripts are just controllers written in groovy

groovy script can do almost anythings as java can do , and much easy.
but in this situation, you can just add an action-view

 <action-view name="action-new-entity-view"
    title="your entity name" model="com.xxx.xxx.XXXEntity">
    <view type="form" name="xxx-entity-form"/>
  </action-view>

then:
onSave=« save,action-new-entity-view »

if you want show new form in popup window, just add view params such as:

    <view-param name="popup" value="true"/>
    <view-param name="show-toolbar" value="false"/>
    <view-param name="show-confirm" value="false"/>
1 « J'aime »

Oh nice, i will test, but for instant i finally found a way and used an observer to override save response with an empty object.
void onTimesheetLineSave(
@Observes @Named(RequestEvent.SAVE) @EntityType(TimesheetLine.class) PostRequest event) {
var ctx = event.getRequest().getContext();
var rsp = event.getResponse();

Map<String, Object> data = event.getRequest().getData();
if (!data.containsKey("scan")) return;

if (event.getResponse().getStatus() != Response.STATUS_SUCCESS) return;

List<Map<String, Object>> dataList = (List<Map<String, Object>>) rsp.getData();

dataList.clear();
TimesheetLine timesheetLine = new TimesheetLine();
timesheetLine.setDate(LocalDate.now());
var newMap = Mapper.toMap(timesheetLine);
newMap.put("$scan", null);
dataList.add(newMap);

}

Ok just tested your solution and it’s not satisfying since that’s open a 2nd tab in application and let the first one open.

Finally onSave=« save,action-new-entity-view,close » do the job , thank you