Fix error in tagData remove action.
This commit is contained in:
parent
58ffaea88d
commit
e473833ccc
1 changed files with 186 additions and 179 deletions
|
@ -117,11 +117,11 @@ public class Presenter
|
|||
/*
|
||||
*
|
||||
*/
|
||||
static protected StringBuffer processChildren (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput)
|
||||
static protected StringBuffer processChildren (Node node, IdsDataById datas, StringBuffer errorOutput)
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processChildren (node, datas, webappPath, "", errorOutput);
|
||||
result = processChildren (node, datas, "", errorOutput);
|
||||
|
||||
//
|
||||
return (result);
|
||||
|
@ -132,10 +132,9 @@ public class Presenter
|
|||
*
|
||||
*/
|
||||
static protected StringBuffer processChildren (Node node,
|
||||
IdsDataById datas,
|
||||
String webappPath,
|
||||
String suffix,
|
||||
StringBuffer errorOutput)
|
||||
IdsDataById datas,
|
||||
String suffix,
|
||||
StringBuffer errorOutput)
|
||||
{
|
||||
StringBuffer result;
|
||||
result = new StringBuffer ();
|
||||
|
@ -182,90 +181,90 @@ public class Presenter
|
|||
|
||||
switch (strategy)
|
||||
{
|
||||
case ONLY_FIRST_ROW:
|
||||
int lineCounter = 0;
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
case ONLY_FIRST_ROW:
|
||||
int lineCounter = 0;
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
lineCounter += 1;
|
||||
if (lineCounter == 1)
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
{
|
||||
lineCounter += 1;
|
||||
if (lineCounter == 1)
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ONLY_FIRST_TWO_ROWS:
|
||||
lineCounter = 0;
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
case ONLY_FIRST_TWO_ROWS:
|
||||
lineCounter = 0;
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
lineCounter += 1;
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
{
|
||||
lineCounter += 1;
|
||||
|
||||
if ((lineCounter == 1) || (lineCounter == 2))
|
||||
if ((lineCounter == 1) || (lineCounter == 2))
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ONLY_ROWS_WITH_ID:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
case ONLY_ROWS_WITH_ID:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
{
|
||||
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
|
||||
|
||||
if ((attrs2 != null) &&
|
||||
(attrs2.getNamedItem ("id") != null))
|
||||
if ((attrs2 != null) &&
|
||||
(attrs2.getNamedItem ("id") != null))
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ONLY_ROWS_WITHOUT_ID:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
case ONLY_ROWS_WITHOUT_ID:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
|
||||
if ((attrs2 == null) ||
|
||||
(attrs2.getNamedItem ("id") == null))
|
||||
if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE)
|
||||
{
|
||||
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
|
||||
NamedNodeMap attrs2 = children.item (childIndex).getAttributes ();
|
||||
if ((attrs2 == null) ||
|
||||
(attrs2.getNamedItem ("id") == null))
|
||||
{
|
||||
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (process (children.item (childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ALL_ROWS:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
break;
|
||||
case ALL_ROWS:
|
||||
for (int childIndex = 0; childIndex < childrenCount; childIndex++)
|
||||
{
|
||||
result.append (process (children.item(childIndex), datas, suffix, errorOutput));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -285,16 +284,15 @@ public class Presenter
|
|||
* The ID.
|
||||
*/
|
||||
static protected StringBuffer processElementWithId (Node node,
|
||||
NamedNodeMap attrs,
|
||||
Node idAttr,
|
||||
IdsDataById datas,
|
||||
String webappPath,
|
||||
StringBuffer errorOutput)
|
||||
NamedNodeMap attrs,
|
||||
Node idAttr,
|
||||
IdsDataById datas,
|
||||
StringBuffer errorOutput)
|
||||
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processElementWithId (node, attrs, idAttr, datas, "", webappPath, errorOutput);
|
||||
result = processElementWithId (node, attrs, idAttr, datas, "", errorOutput);
|
||||
|
||||
//
|
||||
return (result);
|
||||
|
@ -316,7 +314,6 @@ public class Presenter
|
|||
NamedNodeMap attrs,
|
||||
Node idAttr,
|
||||
IdsDataById datas,
|
||||
String webappPath,
|
||||
String suffix,
|
||||
StringBuffer errorOutput)
|
||||
{
|
||||
|
@ -334,7 +331,7 @@ public class Presenter
|
|||
|
||||
if (dataCore == null)
|
||||
{
|
||||
result.append (Presenter.processElementBasically (node, datas, webappPath, suffix, errorOutput));
|
||||
result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput));
|
||||
}
|
||||
else if (dataCore instanceof IdData)
|
||||
{
|
||||
|
@ -351,7 +348,7 @@ public class Presenter
|
|||
}
|
||||
|
||||
if ((theClass == null) ||
|
||||
(!theClass.equals ("xid:nodisplay")))
|
||||
(!theClass.equals ("xid:nodisplay")))
|
||||
{
|
||||
// Open the tag.
|
||||
result.append ("<");
|
||||
|
@ -376,7 +373,7 @@ public class Presenter
|
|||
if ((data == null) ||
|
||||
(data.display () == null))
|
||||
{
|
||||
result.append (processChildren (node, datas, webappPath, suffix, errorOutput));
|
||||
result.append (processChildren (node, datas, suffix, errorOutput));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -408,7 +405,7 @@ public class Presenter
|
|||
result.append (processAttributes (attrs, data.getAttributes (), Integer.toString (nLine)));
|
||||
|
||||
if ((node.getChildNodes () == null) &&
|
||||
((data == null) || (data.display () == null)))
|
||||
((data == null) || (data.display () == null)))
|
||||
{
|
||||
// Close the tag.
|
||||
result.append (" />\n");
|
||||
|
@ -423,7 +420,7 @@ public class Presenter
|
|||
// Insert data.
|
||||
if ((data == null) || (data.display () == null))
|
||||
{
|
||||
result.append (processChildren (node, datas, webappPath, suffix, errorOutput));
|
||||
result.append (processChildren (node, datas, suffix, errorOutput));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -441,7 +438,7 @@ public class Presenter
|
|||
// Manage a Hashmap.
|
||||
IdsDataById data = (IdsDataById) tags.elementAt (nLine);
|
||||
|
||||
result.append (Presenter.processElementWithId (node, attrs, idAttr, data, webappPath, Integer.toString (nLine), errorOutput));
|
||||
result.append (Presenter.processElementWithId (node, attrs, idAttr, data, Integer.toString (nLine), errorOutput));
|
||||
result.append ('\n');
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +475,7 @@ public class Presenter
|
|||
*/
|
||||
static protected StringBuffer process (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput)
|
||||
{
|
||||
logger.debug ("Enter");
|
||||
logger.debug ("process - started");
|
||||
String TRANSITIONAL_DTD = "xhtml1-transitional.dtd";
|
||||
String TRANSITIONAL_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 "
|
||||
+ "Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
|
||||
|
@ -495,114 +492,114 @@ public class Presenter
|
|||
name = getClassAttributeValue (node);
|
||||
|
||||
if ((name == null) ||
|
||||
((name != null) &&
|
||||
(!name.equals ("xid:nodisplay"))))
|
||||
((name != null) &&
|
||||
(!name.equals ("xid:nodisplay"))))
|
||||
{
|
||||
int type = node.getNodeType();
|
||||
switch (type)
|
||||
{
|
||||
case Node.DOCUMENT_NODE:
|
||||
{
|
||||
logger.debug ("case Node.DOCUMENT_NODE");
|
||||
DocumentType dt = ((Document) node).getDoctype();
|
||||
|
||||
if (dt != null)
|
||||
case Node.DOCUMENT_NODE:
|
||||
{
|
||||
String publicId = dt.getPublicId();
|
||||
String systemId = dt.getSystemId();
|
||||
logger.debug ("case Node.DOCUMENT_NODE");
|
||||
DocumentType dt = ((Document) node).getDoctype();
|
||||
|
||||
if (systemId.equals(TRANSITIONAL_DTD))
|
||||
if (dt != null)
|
||||
{
|
||||
result.append(TRANSITIONAL_DOCTYPE);
|
||||
String publicId = dt.getPublicId();
|
||||
String systemId = dt.getSystemId();
|
||||
|
||||
if (systemId.equals(TRANSITIONAL_DTD))
|
||||
{
|
||||
result.append(TRANSITIONAL_DOCTYPE);
|
||||
}
|
||||
|
||||
// Log.write(Log.TRACE,"publicId = " + publicId);
|
||||
// Log.write(Log.TRACE,"systemId = " + systemId);
|
||||
}
|
||||
|
||||
// Log.write(Log.TRACE,"publicId = " + publicId);
|
||||
// Log.write(Log.TRACE,"systemId = " + systemId);
|
||||
result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix, errorOutput));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix, errorOutput));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Node.ELEMENT_NODE:
|
||||
{
|
||||
logger.debug ("case Node.ELEMENT_NODE");
|
||||
|
||||
NamedNodeMap attrs = node.getAttributes ();
|
||||
Node idAttr = attrs.getNamedItem ("id");
|
||||
|
||||
if (idAttr != null)
|
||||
case Node.ELEMENT_NODE:
|
||||
{
|
||||
result.append (Presenter.processElementWithId (node,
|
||||
attrs,
|
||||
idAttr,
|
||||
datas,
|
||||
suffix,
|
||||
errorOutput));
|
||||
logger.debug ("case Node.ELEMENT_NODE");
|
||||
|
||||
NamedNodeMap attrs = node.getAttributes ();
|
||||
Node idAttr = attrs.getNamedItem ("id");
|
||||
|
||||
if (idAttr != null)
|
||||
{
|
||||
result.append (Presenter.processElementWithId (node,
|
||||
attrs,
|
||||
idAttr,
|
||||
datas,
|
||||
suffix,
|
||||
errorOutput));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
// handle entity reference nodes
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
{
|
||||
result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput));
|
||||
logger.debug ("case Node.ENTITY_REFERENCE_NODE");
|
||||
|
||||
result.append ('&');
|
||||
result.append (node.getNodeName());
|
||||
result.append (';');
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// handle entity reference nodes
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
{
|
||||
logger.debug ("case Node.ENTITY_REFERENCE_NODE");
|
||||
|
||||
result.append ('&');
|
||||
result.append (node.getNodeName());
|
||||
result.append (';');
|
||||
break;
|
||||
}
|
||||
|
||||
// print cdata sections
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
{
|
||||
logger.debug ("case Node.CDATA_SECTION_NODE");
|
||||
|
||||
result.append ("<![CDATA[");
|
||||
result.append (node.getNodeValue());
|
||||
result.append ("]]>");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// print text
|
||||
case Node.TEXT_NODE:
|
||||
{
|
||||
logger.debug ("case Node.TEXTE_NODE");
|
||||
result.append (restoreEntities (new StringBuffer(node.getNodeValue())));
|
||||
break;
|
||||
}
|
||||
|
||||
// print processing instruction
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
logger.debug ("Node.PROCESSING_INSTRUCTION_NODE");
|
||||
|
||||
result.append ("<?");
|
||||
result.append (node.getNodeName());
|
||||
String data = node.getNodeValue();
|
||||
if ((data != null) && (data.length () > 0))
|
||||
// print cdata sections
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
{
|
||||
result.append (' ');
|
||||
result.append (data);
|
||||
logger.debug ("case Node.CDATA_SECTION_NODE");
|
||||
|
||||
result.append ("<![CDATA[");
|
||||
result.append (node.getNodeValue());
|
||||
result.append ("]]>");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// print text
|
||||
case Node.TEXT_NODE:
|
||||
{
|
||||
logger.debug ("case Node.TEXTE_NODE");
|
||||
result.append (restoreEntities (new StringBuffer(node.getNodeValue())));
|
||||
break;
|
||||
}
|
||||
|
||||
// print processing instruction
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
logger.debug ("Node.PROCESSING_INSTRUCTION_NODE");
|
||||
|
||||
result.append ("<?");
|
||||
result.append (node.getNodeName());
|
||||
String data = node.getNodeValue();
|
||||
if ((data != null) && (data.length () > 0))
|
||||
{
|
||||
result.append (' ');
|
||||
result.append (data);
|
||||
}
|
||||
result.append ("?>");
|
||||
break;
|
||||
}
|
||||
result.append ("?>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//logger.info ("result=" + result);
|
||||
logger.debug ("Exit");
|
||||
logger.debug ("process - ended");
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
@ -610,11 +607,11 @@ public class Presenter
|
|||
/*
|
||||
*
|
||||
*/
|
||||
static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, StringBuffer errorOutput)
|
||||
static StringBuffer processElementBasically (Node node, IdsDataById datas,StringBuffer errorOutput)
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processElementBasically (node, datas, webappPath, "", errorOutput);
|
||||
result = processElementBasically (node, datas, "", errorOutput);
|
||||
|
||||
//
|
||||
return (result);
|
||||
|
@ -624,15 +621,24 @@ public class Presenter
|
|||
/*
|
||||
*
|
||||
*/
|
||||
static StringBuffer processElementBasically (Node node, IdsDataById datas, String webappPath, String suffix, StringBuffer errorOutput)
|
||||
static StringBuffer processElementBasically (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput)
|
||||
{
|
||||
StringBuffer result;
|
||||
logger.debug("processElementBasically - started");
|
||||
result = new StringBuffer ();
|
||||
|
||||
// Open the tag.
|
||||
result.append ('<');
|
||||
result.append (node.getNodeName());
|
||||
|
||||
|
||||
// Build the tag attributes.
|
||||
Attributes tagAttributes;
|
||||
|
||||
result.append (processAttributes (node.getAttributes (),
|
||||
null,
|
||||
suffix));
|
||||
|
||||
//
|
||||
if (node.getChildNodes () == null)
|
||||
{
|
||||
|
@ -642,13 +648,14 @@ public class Presenter
|
|||
{
|
||||
result.append('>');
|
||||
|
||||
result.append (processChildren (node, datas, webappPath, suffix, errorOutput));
|
||||
result.append (processChildren (node, datas, suffix, errorOutput));
|
||||
|
||||
result.append("</");
|
||||
result.append(node.getNodeName());
|
||||
result.append('>');
|
||||
}
|
||||
|
||||
logger.debug("processElementBasically - ended");
|
||||
|
||||
//
|
||||
return (result);
|
||||
|
|
Loading…
Reference in a new issue