Loop Tag

X-Application Version: 3.1.3, 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

Hi,

I need some help on the Loop Tag.

I’ve attached my createUser.jsp file and my User Schema.
I wanted to add line on the Telephone input field by clicking the button, but no additional line is added. And the data that I have entered on the form are being cleared. There is no error generated.

What did i miss out?
User.TSD (5.14 KB)

Sorry, don’t know how to attach two attachment.

Here is my jsp program
CreateUser.jsp (8.9 KB)

Hello.

The problem of your page is that it creates a new document ‘currentUser’ every time when it is invoked. This new document overwrites the existing one with the same name. Overwriting means that the new document is mapped to the workspace and the former one mapped with the same name is not longer accessible.

You can solve the problem using an if-tag that checks whether a document exists.

<xapp:form document=?currentUser?>
  <xapp:if condition="notexist" select="/User">
    <directcommand type="create" ... />
  </xapp:if>

  ?
</xapp:form>
</pre><BR><BR>However, if you invoke the CreateUser.jsp, the page works with 'currentUser' if it exists. It does not create a new one. Which can be an effect you would not like.<BR><BR>One possibility could be:<BR>Add a new workspace Plugin method that checks the existence of a document and its state, e.g.<BR><BR>Within the JSP<BR><pre class="ip-ubbcode-code-pre">
<xapp:if condition="isCreated" arg="currentUser">
   <xapp:directcommand ? />
</xapp:if>
</pre><BR><BR>The Java Code<BR><pre class="ip-ubbcode-code-pre">
package mypackage.mysubpackage;

import com.software.xtools.xapplication.businessdocument.BusinessDocument;
import com.software.xtools.xapplication.businessdocument.BusinessDocumentWorkspace;

class MyPlugin {
    public static String checkDocument(BusinessDocumentWorkspace ws, String docName) {
        BusinessDocument doc = ws.lookup(docName);
        if (doc!=null && doc.getState() == BusinessDocument.CREATED) {
            return ""; // true
        }
        return null; // false
}
</pre><BR><BR>The xapplication.xml of your application<BR><pre class="ip-ubbcode-code-pre">
<plugin>
  <workspace>
     <action name="isCreated"
             method="mypackage.mysubpackage.MyPlugin.checkDocument">
       <arg>arg</arg>
     </action>
     ...
   </workspace>
   ...
</plugin>



I did not try out the code. There may be typos. Let me know if you have problems to understand my proposal.

Before implementing a Plugin the first time have a look at the documentation about Plugins. There is one chapter. A section about advanced concepts shows the use of Plugins and conditional checks.

Bye,
Christian.