Topic - Backbase integration with NK
Topic - Backbase integration with NK Topic - Backbase integration with NK
from forum Solutions Developer
 forum index   my profile   search 
 new topic  post reply 
moderators: pjr tab
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 4-August-2006 11:14
Hello,

I have some problems installing and using Backbase in my module. Now that - with some help - I got rid of cookies the test page in Backbase does not seem to use the stylesheets correctly although when I look at the jetty log the requested CSS-s seem to get loaded.
I am currently bewildered by the number of potential sources for error so any help, experience with Backbase integration would be helpful. (I work on Mac OS X, use NK version 3, and Firefox 1.5.0.6)

thanks,
Balazs
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 4-August-2006 12:49
Hello,

I have done a test to see if the same Backbase code works with another web server. So I installed it under Apache2, and everything is fine. I compare the logs and to me it seems there is no difference. The results are very different though in the browser (with NK/Jetty controls fall apart).

any ideas ?

thanks,
Balazs


Jetty log:
127.0.0.1 - - [04/aug./2006:11:08:10 +0000] "GET /mob1NK/Backbase/3_1_7/skeletons/basic-startup.html HTTP/1.1" 200 1282
127.0.0.1 - - [04/aug./2006:11:08:10 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/boot.js HTTP/1.1" 200 1103
127.0.0.1 - - [04/aug./2006:11:08:10 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/bpc_02.js HTTP/1.1" 200 167693
127.0.0.1 - - [04/aug./2006:11:08:11 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/dls/dls_02.js HTTP/1.1" 200 9229
127.0.0.1 - - [04/aug./2006:11:08:11 +0000] "GET /mob1NK/Backbase/3_1_7/tools/tool_devconfig.xml HTTP/1.1" 200 8838
127.0.0.1 - - [04/aug./2006:11:08:11 +0000] "GET /mob1NK/Backbase/3_1_7/tools/tools.xml HTTP/1.1" 200 15587
127.0.0.1 - - [04/aug./2006:11:08:11 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/dls/dls_13.js HTTP/1.1" 200 4546
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/dls/dls_20.js HTTP/1.1" 200 1487
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/tools/skin/tools.css HTTP/1.1" 200 16931
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/tools/skin/window/backbase-icon.gif HTTP/1.1" 200 225
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/tools/skin/window/close_small.gif HTTP/1.1" 200 925
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/tools/skin/escapeguide.gif HTTP/1.1" 200 11886
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/controls/dynamic/default.xml HTTP/1.1" 200 5482
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/bpc/dls/dls_09.js HTTP/1.1" 200 683
127.0.0.1 - - [04/aug./2006:11:08:12 +0000] "GET /mob1NK/Backbase/3_1_7/controls/dynamic/default.css HTTP/1.1" 200 2214


Apache log

192.168.5.3 - - [04/Aug/2006:13:41:07 +0200] "GET /~mob/Backbase/3_1_7/skeletons/basic-startup.html HTTP/1.1" 200 1282
192.168.5.3 - - [04/Aug/2006:13:41:07 +0200] "GET /~mob/Backbase/3_1_7/bpc/boot.js HTTP/1.1" 200 1103
192.168.5.3 - - [04/Aug/2006:13:41:07 +0200] "GET /~mob/Backbase/3_1_7/bpc/bpc_02.js HTTP/1.1" 200 167693
192.168.5.3 - - [04/Aug/2006:13:41:08 +0200] "GET /~mob/Backbase/3_1_7/bpc/dls/dls_02.js HTTP/1.1" 200 9229
192.168.5.3 - - [04/Aug/2006:13:41:08 +0200] "GET /~mob/Backbase/3_1_7/tools/tool_devconfig.xml HTTP/1.1" 200 8838
192.168.5.3 - - [04/Aug/2006:13:41:08 +0200] "GET /~mob/Backbase/3_1_7/tools/tools.xml HTTP/1.1" 200 15587
192.168.5.3 - - [04/Aug/2006:13:41:08 +0200] "GET /~mob/Backbase/3_1_7/bpc/dls/dls_13.js HTTP/1.1" 200 4546
192.168.5.3 - - [04/Aug/2006:13:41:08 +0200] "GET /~mob/Backbase/3_1_7/bpc/dls/dls_20.js HTTP/1.1" 200 1487
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/tools/skin/tools.css HTTP/1.1" 200 16931
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/controls/dynamic/default.xml HTTP/1.1" 200 5482
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/tools/skin/window/close_small.gif HTTP/1.1" 200 925
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/tools/skin/escapeguide.gif HTTP/1.1" 200 11886
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/tools/skin/window/backbase-icon.gif HTTP/1.1" 200 225
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/bpc/dls/dls_09.js HTTP/1.1" 200 683
192.168.5.3 - - [04/Aug/2006:13:41:09 +0200] "GET /~mob/Backbase/3_1_7/controls/dynamic/default.css HTTP/1.1" 200 2214
Check the mime type of the served CSS
Joined: 7-February-2005
Posts: 404
Location: between ROC and a hard place
Posted: 4-August-2006 13:26
One known problem is that NetKernel, because of the default Java behaviour serves CSS files with a mime type of content/unknown. Try forcing the CSS to be served with the correct mime type by wrapping it in a DPML script such as this:

<instr>
  <type>cast</type>
  <operand>mycss.css</operand>
  <operator>
    <cast>
      <mimetype>text/css</mimetype>
    </cast>
  </operator>
  <target>this:response</target>
</instr>


Not sure if this will help.

Tony
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 4-August-2006 13:40
Thanks for the tip I will give it a try.
kind regards,
Balazs
Casting
Joined: 31-May-2006
Posts: 19
Posted: 7-August-2006 12:24
Hello,

Following your advice I am trying to write a DPML script that would receive the URL as a parameter and do the casting for an arbitrary CSS like this:
<?xml version="1.0" encoding="UTF-8"?>
<idoc>
    <instr>
        <type>cast</type>
        <operand>this:param:param</operand>
        <operator>
            <cast>
                <mimetype>text/css</mimetype>
            </cast>
        </operator>
        <target>this:response</target>
    </instr>
</idoc>

I have trouble with rewriting the URLs referring to CSS files and to pass these URLS to my DPML script. I have tried rewrites like this:
    <rule>
      <match>(ffcpl:.*\.css)</match>
      <to>active:dpml+operand@ffcpl:/resources/css_casting.idoc+param@$1</to>
    </rule>
but obviously it does not work.

If someone has time please help me with some hints.
thanks,
Balazs
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 7-August-2006 13:03
Hello,

I sorted out the rewrite but I do not understand why my other attempt did not work:
  <rule>
      <match>(ffcpl:.*\.css)</match>
      <to>ffcpl:/resources/css_casting.idoc+param@$1</to>
    </rule>

There is a lot of things I can only guess in the above:
- with regard to URL composition I did try to use '?' operator instead of '+' and '=' instead of '@' which did not work. I also assumed the plus sign would only work for active:... statements.
- I still do not know how to pass an argument with rewrites to a DMPL script.

Any help on the above subject would be welcome.

kind regards,
Balazs
Joined: 14-March-2005
Posts: 86
Location: Amsterdam, The Netherlands
Posted: 10-August-2006 09:29
Hi,

Maybe this helps. I use the following rewrite rules in my module.xml:

<rewrite>
  <!-- some static files should get the proper MIME type -->
  <rule>
    <match>ffcpl:/tds/([^+]*.css)(+.*)?</match>
    <to>active:dpml+operand@ffcpl:/utils/mime.idoc+mime@data:text/plain,text/css+file@ffcpl:/$1</to>
  </rule>
  <rule>
    <match>ffcpl:/tds/([^+]*.jnlp)(+.*)?</match>
    <to>active:dpml+operand@ffcpl:/utils/mime.idoc+mime@data:text/plain,application/x-java-jnlp-file+file@ffcpl:/$1</to>
  </rule>
  <rule>
    <match>ffcpl:/tds/([^+]*.jar)(+.*)?</match>
    <to>active:dpml+operand@ffcpl:/utils/mime.idoc+mime@data:text/plain,application/x-java-archive+file@ffcpl:/$1</to>
  </rule>
  <!-- some static files should just get served as they are -->
  <rule>
    <match>ffcpl:/tds/(ipa/[^+]*.jpg)(+.*)?</match>
    <to>ffcpl:/$1</to>
  </rule>
</rewrite>


The ffcpl:/utils/mime.idoc looks as follows:

<idoc>
  <seq>
    <instr>
      <type>StringToCanonicalString</type>
      <operand>this:param:mime</operand>
      <target>var:mime</target>
    </instr>
    <instr>
      <type>xslt2</type>
      <operand>var:mime</operand>
      <operator>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
          <xsl:output method="xml" encoding="utf-8" />
          <xsl:template match="/">
            <cast>
              <mimetype>
                <xsl:value-of select="string" />
              </mimetype>
            </cast>
          </xsl:template>
        </xsl:stylesheet>
      </operator>
      <target>var:mime</target>
    </instr>
    <instr>
      <type>cast</type>
      <operand>this:param:file</operand>
      <operator>var:mime</operator>
      <target>this:response</target>
    </instr>
    <instr>
      <type>toURI</type>
      <operand>this:param:file</operand>
      <target>var:file</target>
    </instr>
    <instr>
      <type>xpur</type>
      <operand>netkernel:module</operand>
      <operator>
        <xpath> module[identity/uri='urn:nl:uu:let:lot:tds:main']/info/source </xpath>
      </operator>
      <target>var:dir</target>
    </instr>
    <instr>
      <type>xslt2</type>
      <operand>var:file</operand>
      <operator>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
          <xsl:output method="xml" encoding="utf-8" />
          <xsl:template match="/">
            <uri>
              <xsl:value-of select="substring-after(/uri,'ffcpl:/')" />
            </uri>
          </xsl:template>
        </xsl:stylesheet>
      </operator>
      <target>var:file</target>
    </instr>
    <instr>
      <type>resolveURI</type>
      <operand>var:file</operand>
      <operator>var:dir</operator>
      <target>var:file</target>
    </instr>
    <if>
      <cond>
        <instr>
          <type>exists</type>
          <operand>var:file</operand>
          <target>this:cond</target>
        </instr>
      </cond>
      <then>
        <instr>
          <type>xslt2</type>
          <operand>var:file</operand>
          <operator>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
              <xsl:output method="xml" encoding="utf-8" />
              <xsl:template match="/">
                <fls>
                  <root>
                    <xsl:value-of select="replace(uri,'[^/]+$','')" />
                  </root>
                  <filter>
                    <xsl:value-of select="concat('.*/',replace(uri,'.*/',''))" />
                  </filter>
                  <lastmodified />
                </fls>
              </xsl:template>
            </xsl:stylesheet>
          </operator>
          <target>var:fls</target>
        </instr>
        <instr>
          <type>serialize</type>
          <operand>var:fls</operand>
          <target>ffcpl:/temp/fls.mime.xml</target>
        </instr>
        <instr>
          <type>fls</type>
          <operator>var:fls</operator>
          <target>var:file</target>
        </instr>
        <instr>
          <type>serialize</type>
          <operand>var:file</operand>
          <target>ffcpl:/temp/file.mime.xml</target>
        </instr>
        <instr>
          <type>xslt2</type>
          <operand>var:file</operand>
          <operator>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
              <xsl:output method="xml" encoding="utf-8" />
              <xsl:template match="/">
                <ms>
                  <xsl:value-of select="//lastmodified[1]" />
                </ms>
              </xsl:template>
            </xsl:stylesheet>
          </operator>
          <target>var:ms</target>
        </instr>
        <instr>
          <type>serialize</type>
          <operand>var:ms</operand>
          <target>ffcpl:/temp/ms.mime.xml</target>
        </instr>
        <instr>
          <type>beanshell</type>
          <operator>ffcpl:/utils/ms2date.bs</operator>
          <ms>var:ms</ms>
          <target>var:lastmodified</target>
        </instr>
        <instr>
          <type>serialize</type>
          <operand>var:lastmodified</operand>
          <target>ffcpl:/temp/lm.mime.xml</target>
        </instr>
        <instr>
          <type>xslt2</type>
          <operand>var:lastmodified</operand>
          <operator>
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
              <xsl:output method="xml" encoding="utf-8" />
              <xsl:template match="/">
                <HTTPResponseCode>
                  <code>200</code>
                  <header>
                    <name>Last-modified</name>
                    <value>
                      <xsl:value-of select="date" />
                    </value>
                  </header>
                </HTTPResponseCode>
              </xsl:template>
            </xsl:stylesheet>
          </operator>
          <target>var:header</target>
        </instr>
        <instr>
          <type>serialize</type>
          <operand>var:header</operand>
          <target>ffcpl:/temp/header.mime.xml</target>
        </instr>
        <instr>
          <type>HTTPResponseCode</type>
          <operand>this:response</operand>
          <param>var:header</param>
          <target>this:response</target>
        </instr>
      </then>
    </if>
  </seq>
</idoc>


This script not only sets the mime type but also sets the modified date (especially needed if you serve WebStart applications using NK). You may want to strip the script a bit as it contains some debug dumps. The ffcpl:/utils/ms2date.bs used by the script looks as follows:


import org.ten60.netkernel.layer1.nkf.*;
import org.ten60.netkernel.layer1.representation.*;
import com.ten60.netkernel.urii.aspect.*;
import org.ten60.netkernel.xml.xda.*;
import org.ten60.netkernel.xml.representation.*;
import com.ten60.netkernel.urii.*;

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

void main()
{
        Date date= new Date();
        try {
                date = new Date(Long.parseLong(context.sourceAspect("this:param:ms",IAspectXDA.class).getXDA().getText("/ms",true)));
    } catch (Exception e) {
                // ignore and use default
    }

        DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
        IURAspect result=new StringAspect("<date>"+df.format(date)+"</date>");

        INKFResponse resp=context.createResponseFrom(result);
        resp.setMimeType("text/xml");
        context.setResponse(resp);
}


For our project I'm also using the combination of Backbase and NK, so we may help eachother out (didn't see your questions before as I was busy moving into a new house).

Succes,

Menzo[/xml]
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 10-August-2006 18:04
Hey!

Thanks a lot! As for the moment I am trying to pull together the Backbase prototype on my Apache installation and when I am done with that I will again attempt NK integration according to your advise.

Thanks again, hope I can give some help in return.

regards,
Balazs
Backbase integration with NK
Joined: 31-May-2006
Posts: 19
Posted: 15-August-2006 11:58
Hello Menzo,

Yesterday evening after finding out hat BB does not like
to cross over web servers with the use of b:url attribute
- which is a pity - I decided to try the NetKernel scripts
you sent me and move Backbase framework to NK.
For most of the time until midnight I struggled with
rewriting rules and cutting my way through module imports
- these are the activities that seem to take most of my
time as a novice NK user - but finally it worked. The only
change I had to make to the code was to escape the '+' sign
because NK complained for dangling characters in my
rewrite regexp. I actually wonder how it works for you.
I also wonder why you did not specify to let xml, xsl and
various image formats through your rewrite rules. Finally
I decided to name them explicitly in specific rewrite tags.

thanks again,
Balazs
Sorry
Joined: 14-March-2005
Posts: 86
Location: Amsterdam, The Netherlands
Posted: 15-August-2006 13:38
Hi Balazs,

I now see that the escapes were lost somewhere during the copy from my editor into the forums HTML form. So I could have saved you the trouble by checking the pasted code, sorry ... I didn't count on loosing backslashes along the way.

I used to serve Backbase through Netkernel using these rewrites without any problem. But currently we serve them through Apache, and our application through NK using the rewrites as suggested in the NK documentation. That way we can easily share the Backbase deployment with various other applications.

How are you coping with the Backbase idiosyncracies? I had many struggles with mismatching behaviour between standard XSL/XPath and (sometimes) incomplete XPath (they claim to be fully XPath 2.0 compliant) and the XSL-like behaviour (here they admit to be different, but still refer to the XSL standard) of Backbase that I moved a lot of my code from the client back to the server. Also the fact that you can't fully edit the XML data islands turned out to be a nuisance ... but well by now I got a (hopefully) complete set of patterns to get our application fully functional (have a look at http://languagelink.let.uu.nl/tds/ for a sneak preview) and it still looks good ;-)

Greetings,

Menzo
 new topic  post reply  To find out about new replies to this post as they occur
please subscribe to one of these feeds:
AtomRSS moderate 
© 2003-2006, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.