You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/11/01 18:12:07 UTC
svn commit: r330095 - in /myfaces/tomahawk/trunk:
src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java
tld/tomahawk.tld
Author: mmarinschek
Date: Tue Nov 1 09:11:58 2005
New Revision: 330095
URL: http://svn.apache.org/viewcvs?rev=330095&view=rev
Log:
fix in collapsible panel, applied patch for ReducedHTMLParser
Modified:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java
myfaces/tomahawk/trunk/tld/tomahawk.tld
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java?rev=330095&r1=330094&r2=330095&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/ReducedHTMLParser.java Tue Nov 1 09:11:58 2005
@@ -49,6 +49,7 @@
private static final int STATE_IN_TAG = 2;
private int offset;
+ private int lineNumber;
private CharSequence seq;
private CallbackListener listener;
@@ -75,15 +76,32 @@
return offset >= seq.length();
}
+ int getCurrentLineNumber() {
+ return lineNumber;
+ }
+
/**
* Advance the current parse position over any whitespace characters.
*/
void consumeWhitespace() {
+ boolean crSeen = false;
+
while (offset < seq.length()) {
char c = seq.charAt(offset);
if (!Character.isWhitespace(c)) {
break;
}
+
+ // Track line number for error messages.
+ if (c == '\r') {
+ ++lineNumber;
+ crSeen = true;
+ } else if ((c == '\n') && !crSeen) {
+ ++lineNumber;
+ } else {
+ crSeen = false;
+ }
+
++offset;
}
}
@@ -193,6 +211,11 @@
// TODO: should we consider a string to be terminated by a newline?
// that would help with runaway strings but I think that multiline
// strings *are* allowed...
+
+ //
+ // TODO: detect newlines within strings and increment lineNumber.
+ // This isn't so important, though; they aren't common and being a
+ // few lines out in an error message isn't serious either.
StringBuffer stringBuf = new StringBuffer();
boolean escaping = false;
while (!isFinished()) {
@@ -248,12 +271,24 @@
* @param s is a set of characters that should not be discarded.
*/
void consumeExcept(String s) {
+ boolean crSeen = false;
+
while (offset < seq.length()) {
char c = seq.charAt(offset);
if (s.indexOf(c) >= 0) {
// char is in the exception set
return;
}
+
+ // Track line number for error messages.
+ if (c == '\r') {
+ ++lineNumber;
+ crSeen = true;
+ } else if ((c == '\n') && !crSeen) {
+ ++lineNumber;
+ } else {
+ crSeen = false;
+ }
++offset;
}
@@ -268,7 +303,8 @@
int currentTagStart = -1;
String currentTagName = null;
-
+
+ lineNumber = 1;
offset = 0;
while (offset < seq.length())
{
@@ -282,6 +318,10 @@
if (consumeMatch("<!--")) {
// VERIFY: can "< ! --" start a comment?
state = STATE_IN_COMMENT;
+ } else if (consumeMatch("<!")) {
+ // xml processing instruction or <!DOCTYPE> tag
+ // we don't need to actually do anything here
+ log.debug("PI found at line " + getCurrentLineNumber());
} else if (consumeMatch("</")) {
// VERIFY: is "< / foo >" a valid end-tag?
@@ -306,10 +346,17 @@
// the current info until the end of this tag.
currentTagStart = offset - 1;
currentTagName = consumeElementName();
- state = STATE_IN_TAG;
+ if (currentTagName == null) {
+ log.warn("Invalid HTML; bare lessthan sign found at line "
+ + getCurrentLineNumber());
+ // remain in STATE_READY; this isn't really the start of
+ // an xml element.
+ } else {
+ state = STATE_IN_TAG;
+ }
} else {
// should never get here
- throw new Error("Internal error");
+ throw new Error("Internal error at line " + getCurrentLineNumber());
}
continue;
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java?rev=330095&r1=330094&r2=330095&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/collapsiblepanel/HtmlCollapsiblePanel.java Tue Nov 1 09:11:58 2005
@@ -182,6 +182,10 @@
{
return ((Boolean) value).booleanValue();
}
+ else if (value instanceof String)
+ {
+ return Boolean.valueOf((String) value).booleanValue();
+ }
return true;
}
Modified: myfaces/tomahawk/trunk/tld/tomahawk.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/tld/tomahawk.tld?rev=330095&r1=330094&r2=330095&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/tld/tomahawk.tld (original)
+++ myfaces/tomahawk/trunk/tld/tomahawk.tld Tue Nov 1 09:11:58 2005
@@ -1681,42 +1681,42 @@
&html_event_handler_attributes;
&user_role_attributes;
<attribute>
- <name>value</name>
+ <name>collapsed</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
- Boolean value indicating whether the panel is collapsed.
+ Boolean value indicating whether the panel is collapsed by default.
In collapsed state, the body of the panel is not rendered. If you
provide a facet with name 'closedContent', this facet is rendered
instead.
</description>
</attribute>
<attribute>
- <name>var</name>
+ <name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
- The variable which you can use to check for the collapsed
- state of the enclosing component. This is especially
- useful for custom headers you define in a facet with name 'header'.
+ Label for collapsible panel.
</description>
</attribute>
<attribute>
- <name>title</name>
+ <name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
- Title for collapsible panel - shown in header.
+ This variable is defined to hold the value of the
+ component - you can use it for custom headers you define
+ in a facet with name 'header'.
</description>
</attribute>
<attribute>
- <name>titleVar</name>
+ <name>collapsedVar</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
- This variable is defined to hold the title label of the
- component - you can use it for custom headers you define
- in a facet with name 'header'.
+ The variable which you can use to check for the collapsed
+ state of the enclosing component. This is especially
+ useful for custom headers you define in a facet with name 'header'.
</description>
</attribute>
</tag>