Create a new entry after doing commit in ADF

Wouter van Reeven
0 0
Read Time:1 Minute, 3 Second

Imagine this situation: in a call center, the phone rings, an operator creates a new entry in our web application, hangs up and the phone rings again and another new entry needs to be created. In such a case, a rapid insert of new records is wanted and it’s cumbersome to have to click the “New entry” button all the time. At the same time, updating an existing record should not create a new record on commit. Sounds familiar? Read on…

The solution to this problem lies in calling the onCreate method in JhsDataAction right after executing the onCommit method. To do so, create a Java class that extends JhsDataAction and enter a method like this:

public void onCommit(DataActionContext daContext) {
  super.onCommit(daContext);
  super.onCreate(daContext);
}

This will create a new entry everytime the commit button is clicked. Unfortunately, this will also mean that a new entry is created when an existing entry is updated. To fix this problem, check for the “createMode” request parameter. If this is set to “true”, a new entry is created and only then a new entry should be created again. This results in this code:

public void onCommit(DataActionContext daContext) {
  super.onCommit(daContext);
  if ("true".equals(daContext.getHttpServletRequest().getParameter("createMode"))) {
    super.onCreate(daContext);
  }
}

About Post Author

Wouter van Reeven

Wouter is Java consultant at AMIS
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Next Post

Storing your Oracle Reports in the database

One can come up with several reasons to store your Oracle Reports output. Especially in cases where it needed to prove to authorities that the document you delivered was not manipulated by the end user. Consider a pharmaceutical customer, they will need to apply to FDA regulation 21CFR11. Or perhaps […]
%d bloggers like this: