cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mats Norén <mats.no...@spectral.se>
Subject Sitemap + Action + AbstractSitemap
Date Wed, 24 Jan 2001 10:06:21 GMT
Hi,
I've been trying a couple of times to pass values from an Action back to
the
sitemap.
I´ve written a simple dummy class called LoginAction which works like a
selector in many ways.

 public Map act (EntityResolver resolver, Map objectModel, String src,
Parameters par) throws Exception {
 HttpServletRequest req = (HttpServletRequest)
objectModel.get(Constants.REQUEST_OBJECT);
 String name = req.getRemoteUser();
 String uri = "";
 if (name != null)
     {
          uri = par.getParameter("logged_in", "");
          System.out.println("User " + name + " logged in..URI set to: "
+
uri);
     }
 else
     {
          uri = par.getParameter("not_logged_in", "");
          System.out.println("User " + name + " not logged in..URI set
to: " +
uri);
     }
     Map tmp = new HashMap(1);
     System.out.println(uri);
     tmp.put("uri", uri);
     return tmp;
}

I thought that it returned a java Map back to the sitemap and that it
could be
retreived by something like (Giacomos example):

<map:match pattern="subscribe/login.html">
    <map:act type="login">
    <parameter name="logged_in" value="forms.xml"/>
    <parameter name="not_logged_in" value="welcome.xml"/>
        <map:generate src="{uri}"/>
    </map:act>
</map:match>

I looked in the substitute function of AbstractSitemap and found that
the List
in my particular case (above) is empty.
I also looked at the generated code for the sitemap (below), and for the
life of me, I
can´t see what goes wrong.


if ((map = wildcardMatch(matcher_wildcard_N25E_expr,
                               objectModel)) != null) {
        log.debug("Matched matcher_wildcard_N25E");
        listOfMaps.add (map);
        param = new Parameters ();
        param.setParameter ("logged_in", substitute(listOfMaps,
"docs/im/subscribe/welcome.xsp"));
        param.setParameter ("not_logged_in", substitute(listOfMaps,
"docs/im/subscribe/login.xsp"));
        map = ((Action) ((ComponentHolder)
super.sitemapComponentManager.lookup("action:login")).get()).act
(environment, objectModel, substitute(listOfMaps, null), param);
        log.debug("Component generator:serverpages( emptyParam  )");
        log.debug("Source={uri}");
        pipeline.setGenerator ("generator:serverpages",
                               substitute(listOfMaps, "{uri}"),
                               emptyParam);
        if ("content".equals(cocoon_view)) {
          return view_content (pipeline, listOfMaps, environment);
        }
        if ("links".equals(cocoon_view)) {
          log.debug("View links");
          return view_links (pipeline, listOfMaps, environment);
        }

        // performing link translation
        if (environment.getObjectModel().containsKey(
              Cocoon.LINK_OBJECT)) {
          pipeline.addTransformer ("!transformer:link-translator!",
                                   null, emptyParam);
        }
        log.debug("Component serializer:html( emptyParam  )");
        pipeline.setSerializer ("serializer:html", null, emptyParam);
        if (true)
          return pipeline.process (environment);
        listOfMaps.remove (listOfMaps.size() - 1);
      }

The pipeline component tries to retrieve the value for {uri}, it strips
the brackets and does a get("uri") on the empty Map. naturally this
returns null but where does it all go wrong?

Appreciate a quick answer since I have to convince the other teammembers
that Cocoon is the right way to go and to do that I have to have a
semi-functional example up and running at the end of the week.

/Regards Mats

Mime
View raw message