diff --git a/build/classes/fr/devinsy/xid/Presenter.class b/build/classes/fr/devinsy/xid/Presenter.class index caeba96..11a8694 100644 Binary files a/build/classes/fr/devinsy/xid/Presenter.class and b/build/classes/fr/devinsy/xid/Presenter.class differ diff --git a/src/fr/devinsy/xid/Presenter.java b/src/fr/devinsy/xid/Presenter.java index 6f8b5c6..6d2d1d3 100644 --- a/src/fr/devinsy/xid/Presenter.java +++ b/src/fr/devinsy/xid/Presenter.java @@ -301,121 +301,6 @@ public class Presenter } - - /** - * Includes another file into the current page. - * - * @param node - * @param attrMap - * @param idAttr - */ - static protected StringBuffer processObjectTag (Node node, - NamedNodeMap attrMap, - Node idAttr, - IdsDataById datas, - String webappPath, - StringBuffer errorOutput) - { - StringBuffer result; - - result = new StringBuffer (); - - // Find codetype. - String codetype; - if (attrMap == null) - { - codetype = null; - } - else if (attrMap.getNamedItem ("codetype") == null) - { - codetype = null; - } - else - { - codetype = attrMap.getNamedItem ("codetype").getNodeValue (); - } - - // Check tag requirements. - if ((attrMap == null) || - (codetype == null) || - (!codetype.equals ("application/xid")) || - (attrMap.getNamedItem ("data") == null)) - { - // STU: do default action. - Presenter.processElementBasically (node, datas, webappPath, errorOutput); - } - else - { - logger.debug ("object action"); - result.append (""); - - // Build the file name. - String htmlFileName = webappPath + attrMap.getNamedItem ("data").getNodeValue (); - - - // Load file in tree. - Document childDoc = null; - try - { - childDoc = fileToTree (htmlFileName, errorOutput); - } - catch (Exception ex) - { - errorOutput.append ("unable to build the file tree"); - logger.debug ("unable to build the file tree"); - } - - // Extract the 'body' section. - Node body = null; - try - { - NodeList nodes = childDoc.getElementsByTagName ("body"); - - if (nodes.getLength () == 0) - { - errorOutput.append ("no body tag in include html"); - logger.debug ("no body tag in include html"); - } - else - { - body = nodes.item(0); - } - } - catch (Exception e) - { - errorOutput.append ("error getting child"); - logger.debug ("error getting child"); - } - - // Process the body child as part of the primary tree. - if (body == null) - { - errorOutput.append ("xid object body empty."); - } - else - { - NodeList bodyChildren = body.getChildNodes (); - - if (bodyChildren != null) - { - int childCount = bodyChildren.getLength (); - for (int childCounter = 0; childCounter < childCount; childCounter++) - { - result.append (process (bodyChildren.item (childCounter), datas, webappPath, errorOutput)); - } - } - } - - // - result.append (""); - } - logger.debug ("end of object action"); - // - return (result); - } - - - /** * Processes a node that has dynamic content. Calls the appropriate code * generator method, depending on the tag. @@ -468,62 +353,103 @@ public class Presenter String tag = node.getNodeName(); - if (tag.equals ("object")) + String idValue = idAttr.getNodeValue(); + + logger.debug ("tag=" + tag); + + // Get data of this id. + IdDataCore dataCore = datas.get (idAttr.getNodeValue ()); + + if (dataCore == null) { - result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); + result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); } - else + else if (dataCore instanceof IdData) { - String idValue = idAttr.getNodeValue(); + IdData data = (IdData) dataCore; - logger.debug ("tag=" + tag); - - // Get data of this id. - IdDataCore dataCore = datas.get (idAttr.getNodeValue ()); - - if (dataCore == null) + String theClass; + if (data == null) { - result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); + theClass = null; } - else if (dataCore instanceof IdData) + else { - IdData data = (IdData) dataCore; + theClass = data.getAttributes ().getAttribute ("class"); + } - String theClass; - if (data == null) + if ((theClass == null) || + (!theClass.equals ("xid:nodisplay"))) + { + // Open the tag. + result.append ("<"); + result.append (node.getNodeName()); + + // Build attributes. + result.append (processAttributes (attrs, data.getAttributes (), suffix)); + + if ((node.getChildNodes () == null) && + ((data == null) || (data.display () == null))) { - theClass = null; + // Close the tag. + result.append (" />"); } else { - theClass = data.getAttributes ().getAttribute ("class"); - } + result.append ('>'); - if ((theClass == null) || - (!theClass.equals ("xid:nodisplay"))) + // CHANGED, cpm: + + // Insert data. + if ((data == null) || + (data.display () == null)) + { + result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); + } + else + { + result.append (data.display ()); + } + + // Close the tag. + result.append ("'); + } + } + } + else if (dataCore instanceof IdsDataByIndex) + { + IdsDataByIndex tags = (IdsDataByIndex) dataCore; + + int nbLines = tags.size (); + for (int nLine = 0; nLine < nbLines; nLine++) + { + if (tags.elementAt (nLine) instanceof IdData) { + IdData data = (IdData) tags.elementAt (nLine); + // Open the tag. result.append ("<"); result.append (node.getNodeName()); - // Build attributes. - result.append (processAttributes (attrs, data.getAttributes (), suffix)); + result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine))); if ((node.getChildNodes () == null) && ((data == null) || (data.display () == null))) { // Close the tag. - result.append (" />"); + result.append (" />\n"); } else { result.append ('>'); - // CHANGED, cpm: + + // CHANGED, cpm // Insert data. - if ((data == null) || - (data.display () == null)) + if ((data == null) || (data.display () == null)) { result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); } @@ -535,70 +461,22 @@ public class Presenter // Close the tag. result.append ("'); + result.append (">\n"); } } - } - else if (dataCore instanceof IdsDataByIndex) - { - IdsDataByIndex tags = (IdsDataByIndex) dataCore; - - int nbLines = tags.size (); - for (int nLine = 0; nLine < nbLines; nLine++) + else { - if (tags.elementAt (nLine) instanceof IdData) - { - IdData data = (IdData) tags.elementAt (nLine); + // Manage a Hashmap. + IdsDataById data = (IdsDataById) tags.elementAt (nLine); - // Open the tag. - result.append ("<"); - result.append (node.getNodeName()); - - result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine))); - - if ((node.getChildNodes () == null) && - ((data == null) || (data.display () == null))) - { - // Close the tag. - result.append (" />\n"); - } - else - { - result.append ('>'); - - - // CHANGED, cpm - - // Insert data. - if ((data == null) || (data.display () == null)) - { - result.append (processChildren (node, datas, webappPath, suffix, errorOutput)); - } - else - { - result.append (data.display ()); - } - - // Close the tag. - result.append ("\n"); - } - } - else - { - // Manage a Hashmap. - IdsDataById data = (IdsDataById) tags.elementAt (nLine); - - result.append (Presenter.processElementWithId (node, attrs, idAttr, data, webappPath, Integer.toString (nLine), errorOutput)); - result.append ('\n'); - } + result.append (Presenter.processElementWithId (node, attrs, idAttr, data, webappPath, Integer.toString (nLine), errorOutput)); + result.append ('\n'); } } - else - { - logger.warn ("Unknow type of IdDataId"); - } + } + else + { + logger.warn ("Unknow type of IdDataId"); } // @@ -694,17 +572,7 @@ public class Presenter } else { - - String tag = node.getNodeName(); - - if (tag.equals ("object")) - { - result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); - } - else - { - result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); - } + result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput)); } break;