コード例 #1
0
  public static String getNodeReference(
      Node node,
      boolean cacheIfPossible,
      boolean errIfNull,
      ClientDocumentStfulDelegateImpl clientDoc) {
    // El código devuelto debe ser enviado al cliente y ejecutado pues puede llevar información de
    // cacheado y haber sido cacheado ahora en el servidor
    if (node == null)
      if (errIfNull) throw new ItsNatException("No specified node");
      else return "null";

    ItsNatStfulDocumentImpl itsNatDoc = clientDoc.getItsNatStfulDocument();
    Document doc = itsNatDoc.getDocument();
    if (node == ((DocumentView) doc).getDefaultView()) return "itsNatDoc.win";
    else if (node == doc) return "itsNatDoc.doc";
    else if (node == doc.getDoctype()) return "itsNatDoc.doc.doctype";
    else if (node == doc.getDocumentElement()) return "itsNatDoc.doc.documentElement";

    // Es una tentación considerar también el caso document.body pero creo recordar
    // que en Safari y XHTML el API DOM no es el HTML DOM sino DOM Core a secas.

    // node no puede ser nulo, ya está comprobado antes
    NodeLocationImpl nodeLoc = clientDoc.getNodeLocation(node, cacheIfPossible);
    return getNodeReference(
        nodeLoc,
        errIfNull); // errIfNull puede ser false si se quiere, es redundante pues ya se chequeó
    // antes
  }