TopLink JPA inside EJB 3.0 Container (JDeveloper 10.1.3)
Application designed satisfies same business requirements
as [1] and doesn't contain any hands written code line
for creating new orders and editing existing.
Deleting orders from Master-Detail page requieres modifying of
default method embedded into JSF managed Bean.
Import jpauser schema created in [2] in JDeveloper 10.1.3
environment. Tune Jdeveloper 10.1.3 environment to complete the task and generate Session EJB 3.0 for TopLink POJOs imported from jpauser schema.
Create all JSF pages (as *.jspx files backing up UI to Managed Beans),invoke method persistEntity(Object entity) for "Creation order" page (for particular item) , invoke method mergeEntity(Object entity) for "Editing order" page (for particular item)
Create table form has been used for data input.
Method persistEntity() refreshes target screen automatically.
Drag and drop persistEntity(Object) from Data Controls into
JSP area covering button "Submit".
Next step - edit action binding for the "persistEntity" button:
Same action should be performed for "order editing"
page regarding mergeEntity(Object entity) method and editing action binding for corresponding button.
Drag and drop "Delete" button of OrderTable from Data Controls:
Action invoked by "Delete" button (manual intervention):
Code details:
public String commandButton9_action() {
// Delete row from table
BindingContainer bindings1 = getBindings();
OperationBinding operationBinding1 =
bindings1.getOperationBinding("removeEntity");
Object result1 = operationBinding1.execute();
if (!operationBinding1.getErrors().isEmpty()) {
return null;
}
// Refresh detail table screen view
OperationBinding operationBinding =
bindings.getOperationBinding("Delete");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
return null;
}
As of June 21 2006 I found out that described method works only in
Jdeveloper 10.1.3 environment, project stops working properly even been deployed to standalone OC4J instance shipped with Jdeveloper
The reason of mistake is restarting of embedded OC4J instance with apps every time when apps restarts. Otherwise Master – Detail page won’t be properly refreshed after joint invocation removeEntity() & Delete.
View workaround for mentioned issue:-
Refreshing Master-Detail JSF page after inserting or deleting row from Detail table
Runtime screenshots:
Main page:
Orders for particular item:
Creating new order:
References.
1.http://www.oracle.com/technology/products/ias/toplink/jpa/tutorials/jsf-jpa-tutorial.html
2.http://bderzhavets.blogspot.com/2006/05/build-web-application-jsf-using-jpa.html
public String commandButton9_action() {
// Delete row from table
BindingContainer bindings1 = getBindings();
OperationBinding operationBinding1 =
bindings1.getOperationBinding("removeEntity");
Object result1 = operationBinding1.execute();
if (!operationBinding1.getErrors().isEmpty()) {
return null;
}
// Refresh detail table screen view
OperationBinding operationBinding =
bindings.getOperationBinding("Delete");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
return null;
}