Presenter manage TagsData.
This commit is contained in:
parent
cb58af469b
commit
d0606fe62e
7 changed files with 75 additions and 6 deletions
Binary file not shown.
Binary file not shown.
BIN
dist/test.jar
vendored
BIN
dist/test.jar
vendored
Binary file not shown.
BIN
dist/xid.jar
vendored
BIN
dist/xid.jar
vendored
Binary file not shown.
|
@ -483,7 +483,47 @@ public class Presenter
|
|||
}
|
||||
else if (dataCore instanceof TagsData)
|
||||
{
|
||||
TagsData data = (TagsData) dataCore;
|
||||
TagsData tags = (TagsData) dataCore;
|
||||
|
||||
int nbLines = tags.size ();
|
||||
for (int nLine = 0; nLine < nbLines; nLine++)
|
||||
{
|
||||
TagData data = (TagData) tags.elementAt (nLine);
|
||||
|
||||
// Open the tag.
|
||||
result.append ("<");
|
||||
result.append (node.getNodeName());
|
||||
|
||||
// Build attributes.
|
||||
result.append (processAttributes (attrs, data));
|
||||
|
||||
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, webappPath, errorOutput));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (data.display ());
|
||||
}
|
||||
|
||||
// Close the tag.
|
||||
result.append ("</");
|
||||
result.append (node.getNodeName());
|
||||
result.append (">\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dataCore instanceof TagsDataById)
|
||||
{
|
||||
|
|
|
@ -79,9 +79,9 @@ public class TagsDataById extends HashMap<String, TagDataCore> implements TagDat
|
|||
|
||||
// Be sure that lines are existing.
|
||||
int nbLines = tags.size ();
|
||||
for (int nLine = nbLines; nLine < line; nLine++)
|
||||
for (int nLine = nbLines; nLine < line + 1; nLine++)
|
||||
{
|
||||
tags.set (nLine, new TagData ());
|
||||
tags.add (nLine, new TagData ());
|
||||
}
|
||||
|
||||
// Get item.
|
||||
|
@ -110,9 +110,9 @@ public class TagsDataById extends HashMap<String, TagDataCore> implements TagDat
|
|||
|
||||
// Be sure that lines are existing.
|
||||
int nbLines = tags.size ();
|
||||
for (int nLine = nbLines; nLine < line; nLine++)
|
||||
for (int nLine = nbLines; nLine < line + 1; nLine++)
|
||||
{
|
||||
tags.set (nLine, new TagsDataById ());
|
||||
tags.add (nLine, new TagsDataById ());
|
||||
}
|
||||
|
||||
// Get item.
|
||||
|
|
|
@ -210,7 +210,7 @@ class Test
|
|||
|
||||
|
||||
errorMessage = new StringBuffer ();
|
||||
html = Presenter.doXid ("<div id='lastname' toto='kk'>a last name</div >", datas, "", errorMessage);
|
||||
html = Presenter.doXid ("<div id='lastname'>a last name</div >", datas, "", errorMessage);
|
||||
|
||||
System.out.println ("----------------------------");
|
||||
System.out.println ("datas = new TagsDataId ();");
|
||||
|
@ -222,6 +222,35 @@ class Test
|
|||
System.out.println ("<div id='lastname'>a last name</div>");
|
||||
System.out.println ("=>");
|
||||
System.out.println (html);
|
||||
|
||||
|
||||
// Populate attributes of Test 03.
|
||||
datas = new TagsDataById ();
|
||||
datas.setContent ("words", 0, "alpha");
|
||||
datas.setContent ("words", 1, "bravo");
|
||||
datas.setContent ("words", 2, "charlie");
|
||||
datas.setContent ("words", 3, "delta");
|
||||
datas.setContent ("words", 4, "echo");
|
||||
datas.setContent ("words", 5, "fox");
|
||||
|
||||
|
||||
errorMessage = new StringBuffer ();
|
||||
html = Presenter.doXid ("<ul>\n<li id='words'>a word</li>\n</ul>", datas, "", errorMessage);
|
||||
|
||||
System.out.println ("----------------------------");
|
||||
System.out.println ("datas = new TagsDataId ();");
|
||||
System.out.println ("datas.setContent (\"words\", 0, \"alpha\");");
|
||||
System.out.println ("datas.setContent (\"words\", 1, \"bravo\");");
|
||||
System.out.println ("datas.setContent (\"words\", 2, \"charlie\");");
|
||||
System.out.println ("datas.setContent (\"words\", 3, \"delta\");");
|
||||
System.out.println ("datas.setContent (\"words\", 4, \"echo\");");
|
||||
System.out.println ("datas.setContent (\"words\", 5, \"fox\");");
|
||||
System.out.println ("+");
|
||||
System.out.println ("<ul>");
|
||||
System.out.println ("<li id='words'>a word</li>");
|
||||
System.out.println ("</ul>");
|
||||
System.out.println ("=>");
|
||||
System.out.println (html);
|
||||
System.out.println ("----------------------------");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue