small fix.

This commit is contained in:
administrateur 2007-02-07 07:30:24 +01:00
parent faf7fd7fb0
commit 5bc5964bd6
5 changed files with 173 additions and 186 deletions

Binary file not shown.

View file

@ -60,7 +60,7 @@ class Demo
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("datas.setContent (\"name\", \"Superman\");");
@ -80,7 +80,7 @@ class Demo
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");");
@ -105,7 +105,7 @@ class Demo
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
@ -139,7 +139,7 @@ class Demo
source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n"); source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n");
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println ("datas = new Data ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
@ -194,22 +194,22 @@ class Demo
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW);
System.out.println ("ONLY_FIRST_ROW:"); System.out.println ("ONLY_FIRST_ROW:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID);
System.out.println ("ONLY_ROWS_WITH_ID:"); System.out.println ("ONLY_ROWS_WITH_ID:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID);
System.out.println ("ONLY_ROWS_WITHOUT_ID:"); System.out.println ("ONLY_ROWS_WITHOUT_ID:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS);
System.out.println ("ALL_ROWS:"); System.out.println ("ALL_ROWS:");
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (html); System.out.println (html);
@ -230,7 +230,7 @@ class Demo
source.append (" <h1>three</h1>\n"); source.append (" <h1>three</h1>\n");
source.append ("</div>"); source.append ("</div>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (htmlSource); System.out.println (htmlSource);
System.out.println ("+"); System.out.println ("+");

View file

@ -1,5 +1,3 @@
package xid.test;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import xid.*; import xid.*;
@ -7,7 +5,7 @@ import xid.*;
/** /**
* *
*/ */
class Test class Demo
{ {
static private org.apache.log4j.Logger log; static private org.apache.log4j.Logger log;
@ -33,21 +31,21 @@ class Test
log.info ("... done."); log.info ("... done.");
log.debug ("Exit"); log.debug ("Exit");
log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); log = org.apache.log4j.Logger.getLogger (Demo.class.getName ());
} }
/** /**
* *
*/ */
public static void main(String[] args) public static void main (String[] args)
{ {
System.out.println("Hello World!"); System.out.println("Hello World!");
//test (); //test ();
// //
IdsData datas; Data datas;
IdData tag; IdData tag;
@ -58,33 +56,13 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
tag = new IdData ();
tag.setContent ("Superman");
datas.put ("name", tag);
errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();");
System.out.println ("tag = new IdData ();");
System.out.println ("tag.setContent (\"Superman\");");
System.out.println ("datas.put (\"name\", tag););");
System.out.println ("+");
System.out.println ("<div id='name'>a name</div >");
System.out.println ("=>");
System.out.println (html);
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new IdsData ();
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"name\", \"Superman\");"); System.out.println ("datas.setContent (\"name\", \"Superman\");");
System.out.println ("+"); System.out.println ("+");
System.out.println ("<div id='name'>a name</div >"); System.out.println ("<div id='name'>a name</div >");
@ -94,34 +72,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
tag = new IdData ();
tag.setContent ("Spiderman");
tag.getAttributes ().appendAttribute ("style", "background: blue;");
tag.getAttributes ().appendAttribute ("style", "foreground: red;");
tag.getAttributes ().setAttribute ("class", "nameClass");
datas.put ("lastname", tag);
errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();");
System.out.println ("tag = new IdData ();");
System.out.println ("tag.getAttributes ().setAttribute (\"class\", \"lastnameClass\");");
System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"background: blue;\");");
System.out.println ("tag.getAttributes ().appendAttribute (\"style\", \"foreground: red;\");");
System.out.println ("tag.setContent (\"Spiderman\");");
System.out.println ("datas.put (\"lastname\", tag););");
System.out.println ("+");
System.out.println ("<div id='lastname'>a last name</div>");
System.out.println ("=>");
System.out.println (html);
// Populate attributes of Test 03.
System.out.println ("----------------------------");
datas = new IdsData ();
datas.setContent ("lastname", "Spiderman"); datas.setContent ("lastname", "Spiderman");
datas.appendAttribute ("lastname", "style", "background: blue;"); datas.appendAttribute ("lastname", "style", "background: blue;");
datas.appendAttribute ("lastname", "style", "foreground: red;"); datas.appendAttribute ("lastname", "style", "foreground: red;");
@ -131,7 +82,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");");
System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");");
System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");");
@ -144,7 +95,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("words", 0, "alpha"); datas.setContent ("words", 0, "alpha");
datas.setContent ("words", 1, "bravo"); datas.setContent ("words", 1, "bravo");
datas.setContent ("words", 2, "charlie"); datas.setContent ("words", 2, "charlie");
@ -156,7 +107,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); System.out.println ("datas.setContent (\"words\", 1, \"bravo\");");
System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); System.out.println ("datas.setContent (\"words\", 2, \"charlie\");");
@ -173,7 +124,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "nom", "Jemba");
datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 0, "prenom", "Epo");
datas.setContent ("identity", 1, "nom", "Momon"); datas.setContent ("identity", 1, "nom", "Momon");
@ -190,7 +141,7 @@ class Test
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, "", errorMessage);
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
@ -206,7 +157,7 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setContent ("identity", 0, "nom", "Jemba"); datas.setContent ("identity", 0, "nom", "Jemba");
datas.setContent ("identity", 0, "prenom", "Epo"); datas.setContent ("identity", 0, "prenom", "Epo");
datas.setContent ("identity", 1, "nom", "Momon"); datas.setContent ("identity", 1, "nom", "Momon");
@ -228,7 +179,7 @@ class Test
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");");
System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");");
System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");");
@ -264,14 +215,12 @@ class Test
// Populate attributes of Test 03. // Populate attributes of Test 03.
/*
System.out.println ("----------------------------"); System.out.println ("----------------------------");
datas = new IdsData (); datas = new Data ();
datas.setAttribute ("<div>", "class", "aDivClass"); datas.setAttribute ("<div>", "class", "aDivClass");
datas.setAttribute ("<div>", "style", "background-color: #000000;"); datas.setAttribute ("<div>", "style", "background-color: #000000;");
datas.setAttribute ("number", "style", "background-color: #0000FF;"); datas.setAttribute ("number", "style", "background-color: #0000FF;");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
source = new StringBuffer (); source = new StringBuffer ();
source.append ("<div>\n"); source.append ("<div>\n");
@ -285,13 +234,12 @@ class Test
System.out.println (htmlSource); System.out.println (htmlSource);
System.out.println ("+"); System.out.println ("+");
System.out.println ("datas = new IdsData ();"); System.out.println ("datas = new Data ();");
System.out.println ("datas.setAttribute (\"<div>\", \"class\", \"aDivClass\");"); System.out.println ("datas.setAttribute (\"<div>\", \"class\", \"aDivClass\");");
System.out.println ("datas.setAttribute (\"<div>\", \"style\", \"background-color: #000000;\");"); System.out.println ("datas.setAttribute (\"<div>\", \"style\", \"background-color: #000000;\");");
System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");"); System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");");
System.out.println ("=>"); System.out.println ("=>");
System.out.println (html); System.out.println (html);
*/
} }
} }

View file

@ -91,9 +91,9 @@ public class Presenter
/* /*
* *
*/ */
public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) public StringBuffer doXid (Data datas, StringBuffer errorOutput)
{ {
return (doXid (datas, null, errorOutput)); return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput));
} }
/* /*
@ -168,6 +168,15 @@ public class Presenter
/*
*
*/
static public StringBuffer doXid (String html, Data datas, StringBuffer errorOutput)
{
return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), "", errorOutput));
}
/* /*
* *
*/ */
@ -529,7 +538,13 @@ public class Presenter
* @param attrMap * @param attrMap
* @param idAttr * @param idAttr
*/ */
static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) static protected StringBuffer processObjectTag (Node node,
NamedNodeMap attrMap,
Node idAttr,
IdsDataById datas,
TagsDataById tagsData,
String webappPath,
StringBuffer errorOutput)
{ {
StringBuffer result; StringBuffer result;
@ -550,7 +565,6 @@ public class Presenter
codetype = attrMap.getNamedItem ("codetype").getNodeValue (); codetype = attrMap.getNamedItem ("codetype").getNodeValue ();
} }
// Check tag requirements. // Check tag requirements.
if ((attrMap == null) || if ((attrMap == null) ||
(codetype == null) || (codetype == null) ||
@ -577,7 +591,7 @@ public class Presenter
} }
catch (Exception ex) catch (Exception ex)
{ {
result.append ("unable to build the file tree"); errorOutput.append ("unable to build the file tree");
log.debug ("unable to build the file tree"); log.debug ("unable to build the file tree");
} }
@ -589,7 +603,7 @@ public class Presenter
if (nodes.getLength () == 0) if (nodes.getLength () == 0)
{ {
result.append ("no body tag in include html"); errorOutput.append ("no body tag in include html");
log.debug ("no body tag in include html"); log.debug ("no body tag in include html");
} }
else else
@ -599,19 +613,26 @@ public class Presenter
} }
catch (Exception e) catch (Exception e)
{ {
result.append ("error getting child"); errorOutput.append ("error getting child");
log.debug ("error getting child"); log.debug ("error getting child");
} }
// Process the body child as part of the primary tree. // Process the body child as part of the primary tree.
NodeList bodyChildren = body.getChildNodes (); if (body == null)
if (bodyChildren != null)
{ {
int childCount = bodyChildren.getLength (); errorOutput.append ("xid object body empty.");
for (int childCounter = 0; childCounter < childCount; childCounter++) }
else
{
NodeList bodyChildren = body.getChildNodes ();
if (bodyChildren != null)
{ {
result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput)); int childCount = bodyChildren.getLength ();
for (int childCounter = 0; childCounter < childCount; childCounter++)
{
result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput));
}
} }
} }
@ -677,98 +698,41 @@ public class Presenter
result = new StringBuffer (); result = new StringBuffer ();
String tag = node.getNodeName(); String tag = node.getNodeName();
String idValue = idAttr.getNodeValue();
log.debug ("tag=" + tag); if (tag.equals ("object"))
// Get data of this id.
IdDataCore dataCore = datas.get (idAttr.getNodeValue ());
if (dataCore == null)
{ {
result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
} }
else if (dataCore instanceof IdData) else
{ {
IdData data = (IdData) dataCore; String idValue = idAttr.getNodeValue();
String theClass; log.debug ("tag=" + tag);
if (data == null)
// Get data of this id.
IdDataCore dataCore = datas.get (idAttr.getNodeValue ());
if (dataCore == null)
{ {
theClass = null; result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
} }
else else if (dataCore instanceof IdData)
{ {
theClass = data.getAttributes ().getAttribute ("class"); IdData data = (IdData) dataCore;
}
if ((theClass == null) || String theClass;
(!theClass.equals ("xid:nodisplay"))) if (data == null)
{
// Open the tag.
result.append ("<");
result.append (node.getNodeName());
// Build attributes.
Attributes tagAttributes;
if (tagsData == null)
{ {
tagAttributes = null; theClass = null;
} }
else else
{ {
TagData tagData = tagsData.getId (node.getNodeName ()); theClass = data.getAttributes ().getAttribute ("class");
if (tagData == null)
{
tagAttributes = null;
}
else
{
tagAttributes = tagData.getAttributes ();
}
} }
result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix)); if ((theClass == null) ||
(!theClass.equals ("xid:nodisplay")))
if ((node.getChildNodes () == null) &&
((data == null) || data.display ().equals ("")))
{ {
// Close the tag.
result.append (" />");
}
else
{
result.append ('>');
// Insert data.
if ((data == null) ||
(data.display ().equals ("")))
{
result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput));
}
else
{
result.append (data.display ());
}
// Close the tag.
result.append ("</");
result.append (node.getNodeName());
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. // Open the tag.
result.append ("<"); result.append ("<");
result.append (node.getNodeName()); result.append (node.getNodeName());
@ -792,13 +756,13 @@ public class Presenter
} }
} }
result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine))); result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix));
if ((node.getChildNodes () == null) && if ((node.getChildNodes () == null) &&
((data == null) || data.display ().equals (""))) ((data == null) || data.display ().equals ("")))
{ {
// Close the tag. // Close the tag.
result.append (" />\n"); result.append (" />");
} }
else else
{ {
@ -818,22 +782,87 @@ public class Presenter
// Close the tag. // Close the tag.
result.append ("</"); result.append ("</");
result.append (node.getNodeName()); result.append (node.getNodeName());
result.append (">\n"); result.append ('>');
} }
} }
else }
{ else if (dataCore instanceof IdsDataByIndex)
// Manage a Hashmap. {
IdsDataById data = (IdsDataById) tags.elementAt (nLine); IdsDataByIndex tags = (IdsDataByIndex) dataCore;
result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput)); int nbLines = tags.size ();
result.append ('\n'); 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.
Attributes tagAttributes;
if (tagsData == null)
{
tagAttributes = null;
}
else
{
TagData tagData = tagsData.getId (node.getNodeName ());
if (tagData == null)
{
tagAttributes = null;
}
else
{
tagAttributes = tagData.getAttributes ();
}
}
result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine)));
if ((node.getChildNodes () == null) &&
((data == null) || data.display ().equals ("")))
{
// Close the tag.
result.append (" />\n");
}
else
{
result.append ('>');
// Insert data.
if ((data == null) ||
(data.display ().equals ("")))
{
result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput));
}
else
{
result.append (data.display ());
}
// Close the tag.
result.append ("</");
result.append (node.getNodeName());
result.append (">\n");
}
}
else
{
// Manage a Hashmap.
IdsDataById data = (IdsDataById) tags.elementAt (nLine);
result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput));
result.append ('\n');
}
} }
} }
} else
else {
{ log.warn ("Unknow type of IdDataId");
log.warn ("Unknow type of IdDataId"); }
} }
// //
@ -930,7 +959,17 @@ public class Presenter
} }
else else
{ {
result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
String tag = node.getNodeName();
if (tag.equals ("object"))
{
result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput));
}
else
{
result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput));
}
} }
break; break;

View file

@ -83,7 +83,7 @@ class Test
datas.setContent ("name", "Superman"); datas.setContent ("name", "Superman");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='name'>a name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='name'>a name</div >", datas, errorMessage);
System.out.println (check ("only content change", html, "<div id=\"name\">Superman</div>")); System.out.println (check ("only content change", html, "<div id=\"name\">Superman</div>"));
@ -97,7 +97,7 @@ class Test
datas.setAttribute ("lastname", "class", "nameClass"); datas.setAttribute ("lastname", "class", "nameClass");
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage); html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, errorMessage);
System.out.println (check ("content and attributes", html, "<div class=\"nameClass\" style=\"background: blue;foreground: red;\" id=\"lastname\">Spiderman</div>")); System.out.println (check ("content and attributes", html, "<div class=\"nameClass\" style=\"background: blue;foreground: red;\" id=\"lastname\">Spiderman</div>"));
// Populate attributes of Test 03. // Populate attributes of Test 03.
@ -112,7 +112,7 @@ class Test
errorMessage = new StringBuffer (); errorMessage = new StringBuffer ();
html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, "", errorMessage); html = Presenter.doXid ("<ul>\n <li id='words'>a word</li>\n</ul>", datas, errorMessage);
System.out.println (check ("list assertion 1", html, "<li id=\"words_0\">alpha</li>")); System.out.println (check ("list assertion 1", html, "<li id=\"words_0\">alpha</li>"));
System.out.println (check ("list assertion 2", html, "<li id=\"words_1\">bravo</li>")); System.out.println (check ("list assertion 2", html, "<li id=\"words_1\">bravo</li>"));
@ -138,7 +138,7 @@ class Test
source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n"); source.append (" <tr id='identity'><td>noid</td><td id='nom'>un nom</td><td id='prenom'>un prenom</td></tr>\n");
source.append ("</table>"); source.append ("</table>");
htmlSource = source.toString (); htmlSource = source.toString ();
html = Presenter.doXid (htmlSource, datas, "", errorMessage); html = Presenter.doXid (htmlSource, datas, errorMessage);
System.out.println (check ("table 1 assertion 1", html, "<tr id=\"identity_0\"><td>noid</td><td id=\"nom_0\">Jemba</td><td id=\"prenom_0\">Epo</td></tr>")); System.out.println (check ("table 1 assertion 1", html, "<tr id=\"identity_0\"><td>noid</td><td id=\"nom_0\">Jemba</td><td id=\"prenom_0\">Epo</td></tr>"));
System.out.println (check ("table 1 assertion 2", html, "<tr id=\"identity_1\"><td>noid</td><td id=\"nom_1\">Momon</td><td id=\"prenom_1\">Christian</td></tr>")); System.out.println (check ("table 1 assertion 2", html, "<tr id=\"identity_1\"><td>noid</td><td id=\"nom_1\">Momon</td><td id=\"prenom_1\">Christian</td></tr>"));