Read Next

X-Application Version: 3.1.3
Tamino Version : 3.1.2
Platform : Win2k
WebContainer : Tomcat 3.3a
JDK Version : 1.3.1

Dear all,

Does any know how can I read next/previous document from the resultset using the xapp tag? For example, in the list.jsp, I click into a specific detail to the view.jsp page, how can I display a icon to link to the next/previous document? And how can I display the current position (as the $POS seems don’t exists in the view.jsp page)?

Thanks!
Lun

Hello,

if I understand you right, you want to move the navigation of the document set from the list page to the view page.
Currently, there is not support for single step navigation through a document set. A Plugin on document level could be a solution. What has to be done?


  • Writing a plugin, that returns the next/previous document from a document set. For this, have a look at following code. It may contain typos and errors but reflects the main idea: look into the browse page to find the index of the current document and register the next/previuos document.

    public static void nextDocument(BusinessDocument currentDoc, BusinessDocumentWorkspace ws, String pageSetName, String docName) {
        BusinessDocumentPage p = (BusinessDocumentPage)ws.lookupPage(pageName);
        int idx = getDocumentIndex(currentDoc, p);
        if (idx < 0) {
           // do somethink: document is not found on the current page
        } 
        p.gotoPageWithIndex(p.getPageStartElementNo() + idx + 1);
        
        BusinessDocument nexDoc = p.get(idx + 1 ? p.getPageStartElementNo());
        ws.map(docName, nextDoc);
    }
    
    public static void previousDocument(BusinessDocument currentDoc, BusinessDocumentWorkspace ws, String docSetName, String docName) {
        BusinessDocumentPage p = (BusinessDocumentPage)ws.lookupPage(pageName);
        int idx = getDocumentIndex(currentDoc, p);
        if (idx < 0) {
           // do somethink: document is not found on the current page
        }
        p.gotoPageWithIndex(p.getPageStartElementNo() + idx - 1);
        
        BusinessDocument nexDoc = p.get(idx - 1 ? p.getPageStartElementNo());
        ws.map(docName, nextDoc);
    }
    
    private static int getDocumentIndex(BusinessDocument doc, BusinessDocumentPage p) {
        int result;
    
        String refDocId = doc.getDocumentId();
        for (result = p.getPageCapacity()-1; result >= 0; result--) {
    	BusinessDocument d = p.get(result);
          if (d != null && refDocId.equals(d.getDocumentId()) {
    	   break;
          }
        }
        return result;
    }
    </pre><BR><BR><LI> Compiling the java code into the directory WEB-INF/lib/classes of your application.<BR><BR><LI> Registering the plugin within your xapplication.xml file and adding an action for ?next? and ?previous?<BR><pre class="ip-ubbcode-code-pre">
    <plugins>
        ...
        <document>
          <action name=?nextDoc? 
                  method=?<package of the plugin>.<class name of the plugin>.nextDocument?>
            <arg>workspace</arg>
            <arg>arg</arg>
            <arg>documentName</arg>
          </action>
          <action name=?prevDoc? 
                  method=?<package of the plugin>.<class name of the plugin>.previousDocument?>
            <arg>workspace</arg>
            <arg>arg</arg>
            <arg>documentName</arg>
          </action>
        </document>
        ...
    </plugins>
    
    </pre><BR><BR><LI> Adding these action to your JSPs, e.g.<BR><BR><pre class="ip-ubbcode-code-pre">
    <xapp:action type=?nextDoc? arg=?<name of the browselist>?>...</xapp:action>





Before starting with this task, I recommend you to have a look into X-Applications documentation about plugins.

If you have problems to implement this functionality or if you have questions about the idea behind, send a post to this topic.

Bye,
Christian.