ktlili 2005/06/28 17:42:31 CEST
Modified files:
war/src/java/com/jahia/clipping/Bean UrlBean.java
war/src/java/com/jahia/clipping/util DomUtilities.java
war/src/java/com/jahia/clipping/web/Constant WebConstants.java
war/src/java/com/jahia/clipping/web/html/Impl
DefaultHTMLTransformer.java
war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser
TransformBuilderVisitor.java
UserBuilderVisitor.java
war/src/java/com/jahia/clipping/web/html/Impl/Neko
DomHTMLTransformer.java
Log:
- add select tag processing for both transformer
- fix position input position bug
Revision Changes Path
1.15 +16 -16
webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java.diff?r1=1.14&r2=1.15&f=h
1.6 +7 -6
webclip_builder/war/src/java/com/jahia/clipping/util/DomUtilities.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/util/DomUtilities.java.diff?r1=1.5&r2=1.6&f=h
1.6 +1 -0
webclip_builder/war/src/java/com/jahia/clipping/web/Constant/WebConstants.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/Constant/WebConstants.java.diff?r1=1.5&r2=1.6&f=h
1.18 +31 -5
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java.diff?r1=1.17&r2=1.18&f=h
1.6 +65 -3
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/TransformBuilderVisitor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/TransformBuilderVisitor.java.diff?r1=1.5&r2=1.6&f=h
1.5 +81 -10
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java.diff?r1=1.4&r2=1.5&f=h
1.12 +172 -7
webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java.diff?r1=1.11&r2=1.12&f=h
Index: UrlBean.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/Bean/UrlBean.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UrlBean.java 28 Jun 2005 12:26:03 -0000 1.14
+++ UrlBean.java 28 Jun 2005 15:42:29 -0000 1.15
@@ -597,34 +597,34 @@
* attribute
[EMAIL PROTECTED] editable The feature to be added to the
FormParameter
* attribute
- [EMAIL PROTECTED] paramPosition The feature to be added to the
FormParameter
+ [EMAIL PROTECTED] position The feature to be added to the
FormParameter
* attribute
[EMAIL PROTECTED] Description of the Returned Value
*/
- public FormParamBean addFormParameter(String formParentName, String
formParentId, int formParentPosition, String paramName, String possibleValue,
String type, String visibility, boolean editable, int absolutePosition) {
+ public FormParamBean addFormParameter(String formParentName, String
formParentId, int formParentPosition, String paramName, String possibleValue,
String type, String visibility, boolean editable, int position) {
String formParentHah =
HashUtilities.buildFormHash(formParentName, formParentId, formParentPosition);
- FormParamBean bean = null;
+
+ //handle the form whith multiple possible value
+ int pos = 0;
+ FormParamBean bean =
getFormParamBeanByNameAndFormParentNameAndFormParentId(formParentName,
formParentId, formParentPosition, paramName, pos);
+ if (bean != null &&
(type.equalsIgnoreCase(WebConstants.TYPE_RADIO) ||
type.equalsIgnoreCase(WebConstants.TYPE_SELECT))) {
+ logger.debug("[ Add possible value for " + paramName +
" ]");
+ if (!editable) {
+ logger.warn("[ Already recorded ]");
+ }
+ bean.addPossibleValue(possibleValue);
+ return bean;
+ }
// find the position of the parameter
- int pos = -1;
- do {
+ while (bean != null) {
pos++;
bean =
getFormParamBeanByNameAndFormParentNameAndFormParentId(formParentName,
formParentId, formParentPosition, paramName, pos);
- } while (bean != null);
-
+ }
// buil a param bean whith the correct position
bean = new FormParamBean(this, formParentName, formParentId,
formParentPosition, paramName, type, possibleValue, visibility, pos);
getFormParamBeanListByFormParentHash(formParentHah).add(bean);
- /*
- * if (type.equalsIgnoreCase(WebConstants.TYPE_RADIO)) {
- * logger.debug("[ Add possible value for " + paramName + "
]");
- * if (!editable) {
- * logger.warn("[ Already recorded ]");
- * }
- * bean.addPossibleValue(possibleValue);
- * }
- */
return bean;
}
Index: DomUtilities.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/util/DomUtilities.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DomUtilities.java 23 Jun 2005 16:15:47 -0000 1.5
+++ DomUtilities.java 28 Jun 2005 15:42:30 -0000 1.6
@@ -32,9 +32,10 @@
NodeList result = null;
if (doc == null) {
logger.error("Document is null, can't apply xpath");
- }else{
- // logger.debug(getDocumentAsString(doc));
- }
+ }
+ else {
+ // logger.debug(getDocumentAsString(doc));
+ }
try {
XPathFactory fabrique = XPathFactory.newInstance();
@@ -61,8 +62,8 @@
/**
* Gets the DocumentAsString attribute of the DomUtilities class
*
- [EMAIL PROTECTED] doc Description of Parameter
- [EMAIL PROTECTED] The DocumentAsString value
+ [EMAIL PROTECTED] doc Description of Parameter
+ [EMAIL PROTECTED] The DocumentAsString value
*/
public static String getDocumentAsString(Document doc) {
java.io.StringWriter s = new java.io.StringWriter();
@@ -77,7 +78,7 @@
TransformerFactory factory =
TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- String encoding = "ISO-8859-1";
+ String encoding = "UTF-8";
transformer.setOutputProperty(OutputKeys.ENCODING,
encoding);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
Index: WebConstants.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/Constant/WebConstants.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebConstants.java 28 Jun 2005 12:26:03 -0000 1.5
+++ WebConstants.java 28 Jun 2005 15:42:30 -0000 1.6
@@ -88,5 +88,6 @@
public static String TYPE_FILE = "file";
public static String TYPE_HIDDEN = "hidden";
public static String TYPE_IMAGE = "image";
+ public static String TYPE_SELECT = "select";
}
Index: DefaultHTMLTransformer.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/DefaultHTMLTransformer.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultHTMLTransformer.java 28 Jun 2005 10:40:54 -0000 1.17
+++ DefaultHTMLTransformer.java 28 Jun 2005 15:42:30 -0000 1.18
@@ -21,6 +21,7 @@
private HttpServletRequest httpServletRequest;
private List lastParsingErrors = new ArrayList();
private boolean enableCSS;
+ private Hashtable inputNameHash = new Hashtable();
/**
* Description of the Field
*/
@@ -200,6 +201,31 @@
}
+ /**
+ * Gets the PosAndUpdateInputHash attribute of the
DefaultHTMLTransformer
+ * object
+ *
+ [EMAIL PROTECTED] name Description of Parameter
+ [EMAIL PROTECTED] The PosAndUpdateInputHash value
+ */
+ public int getPosAndUpdateInputHash(String name) {
+ Integer pos = (Integer) inputNameHash.get(name);
+ if (pos == null) {
+ pos = new Integer(0);
+
+ }
+ else {
+ pos = new Integer(pos.intValue() + 1);
+ }
+ inputNameHash.put(name, pos);
+ return pos.intValue();
+ }
+
+ public void resetInputHash(){
+ inputNameHash = new Hashtable();
+ }
+
+
/**
* Gets the RewritedActionValue attribute of the DefaultHTMLTransformer
@@ -219,19 +245,19 @@
if (method == null || method.equalsIgnoreCase("")) {
method = "GET";
}
- formName = notNullValue(formName);
- formId = notNullValue(formId);
+ formName = notNullValue(formName);
+ formId = notNullValue(formId);
logger.debug("Rewrite action form: " + action + "," + method +
"," + formName + "," + formId);
- //test if it's a rewritable url
+ //test if it's a rewritable url
if (!isRewritableUrl(action)) {
return action;
}
- //get the absolute value
+ //get the absolute value
action =
URLUtilities.getHrefAbsoluteValue(getUrlBean().getRedirectUrl(), action);
- //encode the url
+ //encode the url
String[] params = {action, formName, formId, "submitForm",
formPos};
UrlEncoder encoder = new UrlEncoder(getHttpServletRequest(),
getHttpServletResponse(), webBrowserAction, WebConstants.URLENCODER_TYPE_FORM,
params, false, method, true);
return encoder.getEncodedUrl();
Index: TransformBuilderVisitor.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/TransformBuilderVisitor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TransformBuilderVisitor.java 28 Jun 2005 12:26:04 -0000 1.5
+++ TransformBuilderVisitor.java 28 Jun 2005 15:42:30 -0000 1.6
@@ -34,11 +34,10 @@
/**
* Description of the Field
*/
- protected int formParentPosition = 0;
+ protected int formParentPosition = -1;
/**
* Description of the Field
*/
- protected int paramPosition = 0;
private Node firstNode;
private HTMLParserTransformer transformer;
@@ -89,6 +88,13 @@
setFirstNode(tag);
}
+
+ if (tag instanceof BaseHrefTag) {
+ processBaseHrefTag((BaseHrefTag) tag);
+ }
+ // remove target tag
+ processTargetAtt(tag);
+
//refactor javascript that appear in an event attribute
for (int i = 0; i <
WebConstants.JAVASCRIPT_EVENT_NAMES_ARRAY.length; i++) {
String name =
WebConstants.JAVASCRIPT_EVENT_NAMES_ARRAY[i];
@@ -184,6 +190,9 @@
transformer.addParsingErrors(ex.getMessage());
}
}
+ else if (tag instanceof SelectTag) {
+ processSelectTag((SelectTag) tag);
+ }
// inline css
else if (tag instanceof StyleTag) {
@@ -212,6 +221,7 @@
}
+
/**
* Gets the Transformer attribute of the TransformBuilderVisitor object
*
@@ -222,6 +232,26 @@
}
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] tag Description of Parameter
+ */
+ protected void processTargetAtt(Tag tag) {
+ tag.removeAttribute("target");
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] tag Description of Parameter
+ */
+ protected void processBaseHrefTag(BaseHrefTag tag) {
+ tag.removeAttribute("href");
+ }
+
+
/**
* Description of the Method
@@ -352,7 +382,7 @@
//update positon valur
formParentPosition++;
- paramPosition = 0;
+ transformer.resetInputHash();
}
catch (Exception ex) {
throw new WebClippingException("Form tag", ex);
@@ -626,6 +656,37 @@
/**
* Description of the Method
*
+ [EMAIL PROTECTED] tag Description of Parameter
+ */
+ private void processSelectTag(SelectTag tag) {
+ String name = tag.getAttribute("name");
+ if (name == null) {
+ name = "";
+ }
+ String type = WebConstants.TYPE_SELECT;
+ int paramPosition = transformer.getPosAndUpdateInputHash(name);
+ String visibility = "true";
+ NodeList it = tag.getChildren();
+ for (int i = 0; i < it.size(); i++) {
+ Node childNode = it.elementAt(i);
+ if (childNode instanceof OptionTag) {
+ OptionTag op = (OptionTag) childNode;
+ String possibleValue = op.getValue();
+
+ try {
+ transformer.recordFormParam(type,
formParentName, formParentId, formParentPosition, name, possibleValue,
visibility, paramPosition);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Description of the Method
+ *
[EMAIL PROTECTED] tag Description of Parameter
[EMAIL PROTECTED] WebClippingException Description of Exception
*/
@@ -637,6 +698,7 @@
String visibility = Boolean.TRUE.toString();
//Get the properties of the param
String name =
transformer.notNullValue(tag.getAttribute(HTML.Attribute.NAME.toString()));
+ int paramPosition =
transformer.getPosAndUpdateInputHash(name);
String possibleValue =
transformer.notNullValue(tag.getAttribute(HTML.Attribute.VALUE.toString()));
type = transformer.notNullValue(type);
transformer.recordFormParam(type, formParentName,
formParentId, formParentPosition, name, possibleValue, visibility,
paramPosition);
Index: UserBuilderVisitor.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/HTMLParser/UserBuilderVisitor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UserBuilderVisitor.java 27 Jun 2005 15:05:12 -0000 1.4
+++ UserBuilderVisitor.java 28 Jun 2005 15:42:30 -0000 1.5
@@ -7,6 +7,8 @@
import com.jahia.clipping.util.*;
import com.jahia.clipping.web.Constant.*;
import com.jahia.clipping.struts.Util.Constants;
+import org.htmlparser.Node;
+import org.htmlparser.util.NodeList;
/**
* Description of the Class
@@ -40,6 +42,24 @@
setFirstNode(tag);
}
+
+ processTargetAtt(tag);
+
+ if (tag instanceof BaseHrefTag) {
+ processBaseHrefTag((BaseHrefTag) tag);
+ }
+
+ //refactor javascript that appear in an event attribute
+ for (int i = 0; i <
WebConstants.JAVASCRIPT_EVENT_NAMES_ARRAY.length; i++) {
+ String name =
WebConstants.JAVASCRIPT_EVENT_NAMES_ARRAY[i];
+ String value = tag.getAttribute(name);
+ if (value != null) {
+ String url =
getTransformer().getDocument().getUrlBean().getRedirectUrl().toExternalForm();
+ String newValue =
getTransformer().getRefactoredJavascript(url,
Constants.WEB_BROWSER_SHOW_BROWSE, value);
+ tag.setAttribute(name, newValue);
+ }
+ }
+
//logger.debug("[ Current tag: " + tag.getTagName() + "]");
// process ele whith attribut src
if (tag.getAttribute("src") != null) {
@@ -53,12 +73,14 @@
// process body tag
if (tag instanceof BodyTag) {
- /* try {
- processBodyTag((BodyTag) tag);
- }
- catch (WebClippingException ex) {
-
getTransformer().addParsingErrors(ex.getMessage());
- }*/
+ /*
+ * try {
+ * processBodyTag((BodyTag) tag);
+ * }
+ * catch (WebClippingException ex) {
+ * getTransformer().addParsingErrors(ex.getMessage());
+ * }
+ */
}
// process ele whith attribut href
else if (tag.getAttribute("href") != null) {
@@ -102,6 +124,9 @@
getTransformer().addParsingErrors(ex.getMessage());
}
}
+ else if (tag instanceof SelectTag) {
+ processSelectTag((SelectTag) tag);
+ }
// inline css
else if (tag instanceof StyleTag) {
@@ -129,6 +154,7 @@
}
+
/**
* Description of the Method
*
@@ -195,6 +221,47 @@
/**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] tag Description of Parameter
+ */
+ private void processSelectTag(SelectTag tag) {
+ String name = tag.getAttribute(HTML.Attribute.NAME.toString());
+ if (name == null) {
+ name = "";
+ }
+ int paramPosition =
getTransformer().getPosAndUpdateInputHash(name);
+ FormParamBean fBean =
getTransformer().getFormParamBean(formParentName, formParentId,
formParentPosition, name, paramPosition);
+ String formHash = HashUtilities.buildFormHash(formParentName,
formParentId, formParentPosition);
+
+ if (fBean == null) {
+ logger.warn("FormParamBean not found for hash " +
formHash + " and input name " + name + " whith type " +
tag.getAttribute("type"));
+ return;
+ }
+
+ logger.debug("FormParamBean found for hash " + formHash + "
and input name " + name + " whith type " + tag.getAttribute("type"));
+ logger.debug("Used value: " + fBean.getUsedValue());
+ String usedValue = fBean.getUsedValue();
+
+ // select the good option
+ NodeList it = tag.getChildren();
+ for (int i = 0; i < it.size(); i++) {
+ Node childNode = it.elementAt(i);
+ if (childNode instanceof OptionTag) {
+ OptionTag op = (OptionTag) childNode;
+ String possibleValue = op.getValue();
+ if (possibleValue.equalsIgnoreCase(usedValue)) {
+
op.setAttribute(HTML.Attribute.SELECTED.toString(), "selected");
+ }
+ else {
+
op.removeAttribute(HTML.Attribute.SELECTED.toString());
+ }
+ }
+ }
+ }
+
+
+ /**
* Gets the FormParamBean attribute of the UserBuilderVisitor object
*/
@@ -208,8 +275,12 @@
logger.debug(" Input tag found");
try {
String name =
tag.getAttribute(HTML.Attribute.NAME.toString());
- FormParamBean fBean =
getTransformer().getFormParamBean(formParentName,
formParentId,formParentPosition, name,paramPosition);
- String formHash =
HashUtilities.buildFormHash(formParentName, formParentId,formParentPosition);
+ if (name == null) {
+ name = "";
+ }
+ int paramPosition =
getTransformer().getPosAndUpdateInputHash(name);
+ FormParamBean fBean =
getTransformer().getFormParamBean(formParentName, formParentId,
formParentPosition, name, paramPosition);
+ String formHash =
HashUtilities.buildFormHash(formParentName, formParentId, formParentPosition);
if (fBean == null) {
logger.warn("FormParamBean not found for hash "
+ formHash + " and input name " + name + " whith type " +
tag.getAttribute("type"));
@@ -223,8 +294,8 @@
logger.debug("Used value: " + fBean.getUsedValue());
tag.setAttribute("value", fBean.getUsedValue());
- // update possition
- paramPosition++;
+ // update possition
+ paramPosition++;
}
catch (Exception ex) {
throw new WebClippingException("Parser, Input Element",
ex);
Index: DomHTMLTransformer.java
===================================================================
RCS file:
/home/cvs/repository/webclip_builder/war/src/java/com/jahia/clipping/web/html/Impl/Neko/DomHTMLTransformer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DomHTMLTransformer.java 28 Jun 2005 10:40:54 -0000 1.11
+++ DomHTMLTransformer.java 28 Jun 2005 15:42:31 -0000 1.12
@@ -23,6 +23,7 @@
public class DomHTMLTransformer extends DefaultHTMLTransformer {
private DomHTMLDocument document;
+
//Xpath
private final String LINK_ELE_XPATH = "//[EMAIL
PROTECTED]'stylesheet']|//[EMAIL PROTECTED]'text/css']";
private final String INPUT_ELE_XPATH = "//input";
@@ -34,11 +35,13 @@
private final String SYTLE_ELE_XPATH = "//style";
private final String SCRIPT_ELE_XPATH = "//script";
private final String CHEW_ELE_XPATH = "//table";
+ private final String TARGET_ATT_XPATH = "//@target";
+ private final String BASE_ELE_XPATH = "//base";
+ private final String SELECT_ELE_XPATH = "//select";
/**
* Description of the Field
*/
- public static String JAVASCRIPT_EVENT_XPATH =
-
"//@onAbort|//@onBlur|//@onChange|//@onClick|//@onDblClick|//@onDragDrop|//@onError|//@onFocus|//@onKeyDown|//@onKeyPress|//@onKeyUp|//@onLoad|//@onMouseDown|//@onMouseMove|//@onMouseOut|//@onMouseOver|//@onMouseUp|//@onMove|//@onReset|
//@onResize|//@onSelect|//@onSubmit|//@onUnload";
+ public static String JAVASCRIPT_EVENT_XPATH =
"//@onAbort|//@onBlur|//@onChange|//@onClick|//@onDblClick|//@onDragDrop|//@onError|//@onFocus|//@onKeyDown|//@onKeyPress|//@onKeyUp|//@onLoad|//@onMouseDown|//@onMouseMove|//@onMouseOut|//@onMouseOver|//@onMouseUp|//@onMove|//@onReset|
//@onResize|//@onSelect|//@onSubmit|//@onUnload";
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(DomHTMLTransformer.class);
@@ -144,6 +147,13 @@
try {
processMetaTag(userDocument,
Constants.WEB_BROWSER_SHOW_TEST);
+
+ //remove target
+ processTargetAttribute(userDocument);
+
+ //process base ele
+ processBaseElement(userDocument);
+
// add some usefull parameter to each form element
processFormElement(userDocument,
Constants.WEB_BROWSER_SHOW_TEST);
@@ -237,8 +247,15 @@
//processLinkElement(transformedDocument);
processMetaTag(transformedDocument,
Constants.WEB_BROWSER_SHOW_BROWSE);
+ //remove target
+ processTargetAttribute(transformedDocument);
+
+ //process base tag
+ processBaseElement(transformedDocument);
+
//Record
processInputElement(transformedDocument);
+ processSelectElement(transformedDocument);
// add some usefull paramter to each form element
processFormElement(transformedDocument,
Constants.WEB_BROWSER_SHOW_BROWSE);
@@ -333,6 +350,8 @@
+
+
/**
* Description of the Method
*
@@ -585,6 +604,38 @@
*
[EMAIL PROTECTED] doc Description of Parameter
*/
+ private void processTargetAttribute(Document doc) {
+ NodeList atts = DomUtilities.getNodeListByXPath(doc,
TARGET_ATT_XPATH);
+ for (int i = 0; i < atts.getLength(); i++) {
+ Attr att = (Attr) atts.item(i);
+ Element ele = att.getOwnerElement();
+ ele.removeAttributeNode(att);
+ }
+
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] doc Description of Parameter
+ */
+ private void processBaseElement(Document doc) {
+ NodeList eles = DomUtilities.getNodeListByXPath(doc,
BASE_ELE_XPATH);
+ for (int i = 0; i < eles.getLength(); i++) {
+ Element ele = (Element) eles.item(i);
+ ele.removeAttribute("href");
+ }
+
+ }
+
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] doc Description of Parameter
+ */
private void processSytleElement(Document doc) {
logger.debug("[ Process StyleTag ]");
NodeList eleList = DomUtilities.getNodeListByXPath(doc,
this.SYTLE_ELE_XPATH);
@@ -778,7 +829,6 @@
}
else {
-
for (int inputPos = 0; inputPos <
inputList.getLength(); inputPos++) {
try {
Element ele = (Element)
inputList.item(inputPos);
@@ -788,9 +838,10 @@
// Test that the type is a
"valid" one
//Get the properties of the
param
String name =
notNullValue(ele.getAttribute(HTML.Attribute.NAME.toString()));
+ int pos =
getPosAndUpdateInputHash(name);
String possibleValue =
notNullValue(ele.getAttribute(HTML.Attribute.VALUE.toString()));
type = notNullValue(type);
- recordFormParam(type,
formParentName, formParentId, formParentPos, name, possibleValue, visibility,
inputPos);
+ recordFormParam(type,
formParentName, formParentId, formParentPos, name, possibleValue, visibility,
pos);
}
catch (Exception ex) {
addParsingErrors("Parser, Input
Element: " + ex.toString());
@@ -798,6 +849,8 @@
}
}
+ // reset the input hash
+ resetInputHash();
}
}
@@ -808,6 +861,60 @@
*
[EMAIL PROTECTED] doc Description of Parameter
*/
+ private void processSelectElement(Document doc) {
+ NodeList formList = DomUtilities.getNodeListByXPath(doc,
FORM_ELE_XPATH);
+
+ // iterate form Element
+ for (int formParentPos = 0; formParentPos <
formList.getLength(); formParentPos++) {
+ Element form = (Element) formList.item(formParentPos);
+ String formParentName =
form.getAttribute(HTML.Attribute.NAME.toString());
+ String formParentId =
form.getAttribute(HTML.Attribute.ID.toString());
+
+ NodeList selectList =
form.getElementsByTagName(HTML.Tag.SELECT.toString());
+ if (selectList == null) {
+ logger.warn("Select list is empty for form
whith name: " + formParentName);
+
+ }
+ else {
+ //iterate select elemt
+ for (int selectPos = 0; selectPos <
selectList.getLength(); selectPos++) {
+ try {
+ Element ele = (Element)
selectList.item(selectPos);
+ String type =
WebConstants.TYPE_SELECT;
+ String visibility =
Boolean.TRUE.toString();
+ String name =
notNullValue(ele.getAttribute(HTML.Attribute.NAME.toString()));
+ type = notNullValue(type);
+ int pos =
getPosAndUpdateInputHash(name);
+ //iterate option ele
+ NodeList optionList =
form.getElementsByTagName(HTML.Tag.OPTION.toString());
+ for (int optionPos = 0;
optionPos < optionList.getLength(); optionPos++) {
+ Element optEle =
(Element) optionList.item(optionPos);
+ String value =
optEle.getAttribute("value");
+ String possibleValue =
notNullValue(value);
+ recordFormParam(type,
formParentName, formParentId, formParentPos, name, possibleValue, visibility,
pos);
+ }
+
+ }
+ catch (Exception ex) {
+ addParsingErrors("Parser, Input
Element: " + ex.toString());
+ }
+
+ }
+ }
+
+ //reset the input hash
+ resetInputHash();
+ }
+
+ }
+
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] doc Description of Parameter
+ */
private void processUserInputElement(Document doc) {
NodeList formList = DomUtilities.getNodeListByXPath(doc,
FORM_ELE_XPATH);
for (int formPos = 0; formPos < formList.getLength();
formPos++) {
@@ -825,8 +932,9 @@
for (int inputPos = 0; inputPos <
inputList.getLength(); inputPos++) {
Element inputEle = (Element)
inputList.item(inputPos);
String name =
inputEle.getAttribute(HTML.Attribute.NAME.toString());
- FormParamBean fBean =
getFormParamBean(formParentName, formParentId,formPos, name,inputPos);
- String formHash =
HashUtilities.buildFormHash(formParentName, formParentId,formPos);
+ int pos =
getPosAndUpdateInputHash(name);
+ FormParamBean fBean =
getFormParamBean(formParentName, formParentId, formPos, name, pos);
+ String formHash =
HashUtilities.buildFormHash(formParentName, formParentId, formPos);
if (fBean == null) {
logger.warn("FormParamBean not
found for hash " + formHash + " and input name: " + name + " whith type: " +
inputEle.getAttribute("type"));
@@ -842,6 +950,63 @@
}
}
+ //reset the input hash
+ resetInputHash();
+ }
+
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED] doc Description of Parameter
+ */
+ private void processUserSelectElement(Document doc) {
+ NodeList formList = DomUtilities.getNodeListByXPath(doc,
FORM_ELE_XPATH);
+ for (int formPos = 0; formPos < formList.getLength();
formPos++) {
+ Element form = (Element) formList.item(formPos);
+ String formParentName =
form.getAttribute(HTML.Attribute.NAME.toString());
+ String formParentId =
form.getAttribute(HTML.Attribute.ID.toString());
+ NodeList selectList =
form.getElementsByTagName(HTML.Tag.SELECT.toString());
+ if (selectList == null) {
+ logger.warn("Input list is empty for form whith
name: " + formParentName);
+
+ }
+ else {
+ //iterate select ele
+ for (int selectPos = 0; selectPos <
selectList.getLength(); selectPos++) {
+ Element selectEle = (Element)
selectList.item(selectPos);
+ String name =
selectEle.getAttribute(HTML.Attribute.NAME.toString());
+ int pos =
getPosAndUpdateInputHash(name);
+ FormParamBean fBean =
getFormParamBean(formParentName, formParentId, formPos, name, pos);
+ String formHash =
HashUtilities.buildFormHash(formParentName, formParentId, formPos);
+
+ if (fBean == null) {
+ logger.warn("FormParamBean not
found for hash " + formHash + " and input name: " + name + " whith type: " +
selectEle.getAttribute("type"));
+ return;
+ }
+
+ logger.debug("FormParamBean found for
hash " + formHash + " and input name " + name + " whith type " +
selectEle.getAttribute("type"));
+ logger.debug("Used value: " +
fBean.getUsedValue());
+ String usedValue = fBean.getUsedValue();
+ //iterate option ele in order to select
the good option
+ NodeList optionList =
form.getElementsByTagName(HTML.Tag.OPTION.toString());
+ for (int optionPos = 0; optionPos <
optionList.getLength(); optionPos++) {
+ Element optEle = (Element)
optionList.item(optionPos);
+ String value =
optEle.getAttribute("value");
+ if
(value.equalsIgnoreCase(usedValue)) {
+
optEle.setAttribute("selected", "selected");
+ }
+ else {
+
optEle.removeAttribute("selected");
+ }
+ }
+ }
+ }
+
+ //reset the input hash
+ resetInputHash();
}
}
@@ -898,7 +1063,7 @@
String method = formEle.getAttribute("method");
String formName = formEle.getAttribute("name");
String formId = formEle.getAttribute("id");
- formEle.setAttribute("action",
getRewritedActionValue(url, method, formName, formId,""+formPos,
webBrowserAction));
+ formEle.setAttribute("action",
getRewritedActionValue(url, method, formName, formId, "" + formPos,
webBrowserAction));
formEle.setAttribute("method", "post");
formEle.removeAttribute("target");