0 Replies Latest reply on Sep 1, 2004 10:07 AM by yxyang

    question on DelegateContext

      Hello,

      I checked out the nuke-1.1 from cvs.

      i pasted parts of the process(PageResult result, final Writer writer) method of ThemeTemplate.java file in the following.

      Q1: who will populate/initialize the PageResult ?
      Q2: What are contained in the result.getFragments()?

      Thanks a lot.

      yang

      ---------------------------------------------------------------------
      public void process(PageResult result, final Writer writer){

      String[] names = new String[]{"left", "middle", "right"};
      DelegateContext ctx = new DelegateContext();
      for (int i = 0; i < names.length; i++)
      {
      String name = names;
      for (Iterator j = result.getFragments(i).iterator(); j.hasNext();)
      {
      final PageFragment fragment = (PageFragment)j.next();
      ctx.append(name, new Context()
      {
      public String get(String key)
      {
      if ("TITLE".equals(key))
      {
      return fragment.getTitle();
      }
      else if ("CONTENT".equals(key))
      {
      try
      {
      process(fragment.getBody(), writer);
      }
      catch (IOException e)
      {
      log.error("", e);
      }
      }
      return "";
      }
      public Context put(String key, String value)
      {
      return this;
      }
      public Iterator childIterator(String name)
      {
      return Collections.EMPTY_LIST.iterator();
      }
      });
      }
      }
      --------------------------