Add some operations before or after the commitment of Create

Hi,

I have two collections (just say coll_A and coll_B) in a Tamino database. And I used the X-Application to generate the JSP pages for coll_A.

Now, I want to add some operations before or after the commitment of Create / Delete through the JSP pages generated.

The possible operations being added are, for example:
1) after creating a record in coll_A, I want to add a record into coll_B which has some information relating to the record in coll_A.
2) after deleteing a record in coll_A, I want to delete the correspongding record in coll_B.

I need to make sure that “transaction” is being used. That means, just say, if the record in coll_B could not be deleted due to some unexpected reasons, the “delete” operation for the record in coll_A should be rolled back.

How can I add the Java coding before or after the commitment of the Create / Delete actions in the JSP pages? Do I need to modify the tag library? Any other simpler methods?

Can anyone help me? Thanks a lot!

Andy Ho

Hello,

a possible solution could be a plugin on document level. Assume your document of doctype ?docA? has to be committed. Then, the following action could be pluged in:

<xapp:action type=?commitA? ...>...</xapp:action>
</pre><BR><BR>The definition of this action must be added to your xapplication.xml file.<BR><BR><pre class="ip-ubbcode-code-pre">
<plugins>
   <document name=?DocA?>
    <action name=?commitA?
                 method=?myPackage.mySubPackage.MyClass.commitDocumentA?>
      <arg>workspace</arg>
     </action>
   </document>
   ...
</plugins>
</pre><BR><BR>Here the name of the action is assigned to the method commitDocumentA that implements the functionality of the action, e.g.<BR><BR><pre class="ip-ubbcode-code-pre">
package myPackage.mySubPackage;

public class MyClass {
    public static void commitDocumentA(BusinessDocument doc, BusinessDocumentWorkspace ws) {
        Store s = ws.getStore();
        BusinessDocument docB = ws.read(...);
        if (...) {
           List docs = new ArrayList();
           docs.add(docA);
           docs.add(docB);
           SingleBusinessDocument.commitAll(docs);
        }
    }
}



The class implementing the functionality must be compiled into the directory WEB-INF/classes of your application.

Using a plugin, it is not necessary to add a new tag. However, before starting with this task have a look into the documentation of X-Application 3.1.3. It contains a chapter about plugins.

The example I have written may contain errors and typos because I wrote it directly into the editor without trying out the code. If you have questions or problems with this example, send me a new post.

Bye,
Christian.

Hello,

this topic will be moved to the Assistance Forum in the next days.
The assistance forum is intended to be used for technical questions and answers.

Thank you for your understanding.

Regards,
Christian.