예제 #1
0
 // two methods for the RenderSystemDecoder interface
 public void normalizeRequestMap(Map requestparams) {
   String key = RenderUtil.findCommandParams(requestparams);
   if (key != null) {
     String params = key.substring(FossilizedConverter.COMMAND_LINK_PARAMETERS.length());
     RenderUtil.unpackCommandLink(params, requestparams);
     requestparams.remove(key);
   }
 }
예제 #2
0
  // This method is almost entirely dialect-invariant - awaiting final
  // factorisation of RenderSystem
  public int renderComponent(
      RenderSystemContext rsc, UIContainer context, UIComponent torendero, XMLLump lump) {
    int lumpindex = lump.lumpindex;
    XMLLump[] lumps = lump.parent.lumps;
    int nextpos = -1;
    XMLLump outerendopen = lump.open_end;
    XMLLump outerclose = lump.close_tag;

    nextpos = outerclose.lumpindex + 1;

    XMLLumpList payloadlist =
        lump.downmap == null ? null : lump.downmap.headsForID(XMLLump.PAYLOAD_COMPONENT);
    XMLLump payload = payloadlist == null ? null : payloadlist.lumpAt(0);

    boolean iselide = lump.rsfID.startsWith(XMLLump.ELISION_PREFIX);

    XMLLump endopen = outerendopen;
    XMLLump close = outerclose;
    XMLLump uselump = lump;

    HashMap attrcopy = new HashMap();
    attrcopy.putAll((payload == null ? uselump : payload).attributemap);
    attrcopy.remove(XMLLump.ID_ATTRIBUTE);

    TagRenderContext rendercontext =
        new TagRenderContext(
            attrcopy, uselump, endopen, close, rsc.pos, rsc.xmlw, nextpos, iselide);

    idRelationRewriter.rewrite(rsc.idrewritemap, rendercontext, context);

    // if there is no peer component, it might still be a static resource holder
    // that needs URLs rewriting.
    // we assume there is no payload component here, since there is no producer
    // ID that might govern selection. So we use "outer" indices.
    if (torendero == null) {
      if (lump.rsfID.indexOf(XMLLump.SCR_PREFIX) == (iselide ? 1 : 0)) {
        String scrname = lump.rsfID.substring(XMLLump.SCR_PREFIX.length() + (iselide ? 1 : 0));
        StaticComponentRenderer scr = scrc.getSCR(scrname);
        if (scr == null) {
          Logger.log.info(
              "Warning: unrecognised static component renderer reference with key "
                  + scrname
                  + " at lump "
                  + lump.toString());
          scr = NullRewriteSCR.instance;
        }
        int tagtype = RenderUtil.renderSCR(scr, rsc.collecteds, rendercontext);
        nextpos =
            tagtype == ComponentRenderer.LEAF_TAG
                ? outerclose.lumpindex + 1
                : outerendopen.lumpindex + 1;
      } else {
        if (rsc.debugrender) {
          renderDebugMessage(
              rsc,
              "Leaf component missing which was expected with template id "
                  + lump.rsfID
                  + " at "
                  + lump.toString());
        }
      }
    } else {
      // else there IS a component and we are going to render it. First make
      // sure we render any preamble.

      if (payload != null) {
        rendercontext.endopen = payload.open_end;
        rendercontext.close = payload.close_tag;
        rendercontext.uselump = payload;
        RenderUtil.dumpTillLump(lumps, lumpindex, payload.lumpindex, rsc.pos);
        lumpindex = payload.lumpindex;
      }

      rsc.IDassigner.adjustForID(attrcopy, torendero);
      decoratormanager.decorate(torendero.decorators, uselump.getTag(), attrcopy);

      // ALWAYS dump the tag name, this can never be rewritten. (probably?!)
      rendercontext.openTag();

      if (torendero instanceof UIBasicListMember) {
        torendero = RenderUtil.resolveListMember(rsc.view, (UIBasicListMember) torendero);
      }
      try {
        componentRenderer.renderComponent(torendero, rsc.view, rendercontext);
      } catch (Exception e) {
        throw UniversalRuntimeException.accumulate(
            e,
            "Error rendering component "
                + torendero.getClass()
                + " with full ID "
                + torendero.getFullID()
                + " at template location "
                + rendercontext.uselump);
      }
      // if there is a payload, dump the postamble.
      if (payload != null) {
        // the default case is initialised to tag close
        if (rendercontext.nextpos == nextpos) {
          RenderUtil.dumpTillLump(
              lumps, rendercontext.close.lumpindex + 1, outerclose.lumpindex + 1, rsc.pos);
        }
      }
      nextpos = rendercontext.nextpos;
    }

    return nextpos;
  }