JBoss Rich Faces SVN: r11010 - trunk/sandbox/ui/editor.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-04 06:33:40 -0500 (Tue, 04 Nov 2008)
New Revision: 11010
Modified:
trunk/sandbox/ui/editor/pom.xml
Log:
add maven antlr plugin
Modified: trunk/sandbox/ui/editor/pom.xml
===================================================================
--- trunk/sandbox/ui/editor/pom.xml 2008-11-04 11:32:25 UTC (rev 11009)
+++ trunk/sandbox/ui/editor/pom.xml 2008-11-04 11:33:40 UTC (rev 11010)
@@ -39,6 +39,23 @@
</library>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>antlr-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <grammars>html-seamtext.g</grammars>
+ </configuration>
+ </plugin>
+
+
</plugins>
</build>
<dependencies>
15 years, 6 months
JBoss Rich Faces SVN: r11009 - trunk/sandbox/ui/editor.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-04 06:32:25 -0500 (Tue, 04 Nov 2008)
New Revision: 11009
Removed:
trunk/sandbox/ui/editor/html-seamtext.g
Log:
moved to the src/main/antlr
Deleted: trunk/sandbox/ui/editor/html-seamtext.g
===================================================================
--- trunk/sandbox/ui/editor/html-seamtext.g 2008-11-04 11:27:53 UTC (rev 11008)
+++ trunk/sandbox/ui/editor/html-seamtext.g 2008-11-04 11:32:25 UTC (rev 11009)
@@ -1,1070 +0,0 @@
-header
-{
- package org.richfaces.antlr;
-}
-
-class HtmlSeamTextParser extends Parser;
-
-options
-{
- k=4;
- defaultErrorHandler=false;
-}
-
-{
- public class HtmlRecognitionException extends RecognitionException {
- Token openingElement;
- RecognitionException wrappedException;
-
- public HtmlRecognitionException(Token openingElement, RecognitionException wrappedException) {
- this.openingElement = openingElement;
- this.wrappedException = wrappedException;
- }
-
- public Token getOpeningElement() {
- return openingElement;
- }
-
- public String getMessage() {
- return wrappedException.getMessage();
- }
-
- public Throwable getCause() {
- return wrappedException;
- }
- }
-
-
- public interface Sanitizer {
-
- public void validateLinkTagURI(Token element, String uri) throws SemanticException;
- public void validateHtmlElement(Token element) throws SemanticException;
- public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException;
- public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException;
- public void escapeSeamTextToken(Token element);
- public String getInvalidURIMessage(String uri);
- public String getInvalidElementMessage(String elementName);
- public String getInvalidAttributeMessage(String elementName, String attributeName);
- public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value);
-
- }
-
- public static class DefaultSanitizer implements HtmlSeamTextParser.Sanitizer {
-
- protected java.util.Set<String> attributesWhoseValueIsAURI = new java.util.HashSet(java.util.Arrays.asList(
- "action", "cite", "href", "longdesc", "src", "xlink:href", "xml:base"
- ));
-
-
- protected java.util.Set<String> uriSchemes = new java.util.HashSet(java.util.Arrays.asList(
- "afs", "aim", "callto", "ed2k", "feed", "ftp", "gopher", "http", "https",
- "irc", "mailto", "news", "nntp", "rsync", "rtsp", "sftp", "ssh", "tag",
- "tel", "telnet", "urn", "webcal", "wtai", "xmpp"
- ));
-
- protected java.util.Set<String> acceptableElements = new java.util.HashSet(java.util.Arrays.asList(
- "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote",
- "br", "button", "caption", "center", "cite", "code", "col", "colgroup", "dd",
- "del", "dfn", "dir", "div", "dl", "dt", "em", "fieldset", "font", "form",
- "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "input", "ins", "kbd",
- "label", "legend", "li", "map", "menu", "ol", "optgroup", "option", "p",
- "pre", "q", "s", "samp", "select", "small", "span", "strike", "strong",
- "sub", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead",
- "tr", "tt", "u", "ul", "var", "wbr"
- ));
-
- protected java.util.Set<String> mathmlElements = new java.util.HashSet(java.util.Arrays.asList(
- "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo",
- "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "mspace",
- "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext",
- "mtr", "munder", "munderover", "none"
- ));
-
- protected java.util.Set<String> svgElements = new java.util.HashSet(java.util.Arrays.asList(
- "a", "animate", "animateColor", "animateMotion", "animateTransform",
- "circle", "defs", "desc", "ellipse", "font-face", "font-face-name",
- "font-face-src", "g", "glyph", "hkern", "image", "line", "linearGradient",
- "marker", "metadata", "missing-glyph", "mpath", "path", "polygon",
- "polyline", "radialGradient", "rect", "set", "stop", "svg", "switch", "text",
- "title", "tspan", "use"
- ));
-
- protected java.util.Set<String> acceptableAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "abbr", "accept", "accept-charset", "accesskey", "action", "align", "alt",
- "axis", "border", "cellpadding", "cellspacing", "char", "charoff", "charset",
- "checked", "cite", "class", "clear", "color", "cols", "colspan", "compact",
- "coords", "datetime", "dir", "disabled", "enctype", "for", "frame",
- "headers", "height", "href", "hreflang", "hspace", "id", "ismap", "label",
- "lang", "longdesc", "maxlength", "media", "method", "multiple", "name",
- "nohref", "noshade", "nowrap", "prompt", "readonly", "rel", "rev", "rows",
- "rowspan", "rules", "scope", "selected", "shape", "size", "span", "src",
- "start", "style", "summary", "tabindex", "target", "title", "type", "usemap",
- "valign", "value", "vspace", "width", "xml:lang"
- ));
-
- protected java.util.Set<String> mathmlAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "actiontype", "align", "columnalign", "columnalign", "columnalign",
- "columnlines", "columnspacing", "columnspan", "depth", "display",
- "displaystyle", "equalcolumns", "equalrows", "fence", "fontstyle",
- "fontweight", "frame", "height", "linethickness", "lspace", "mathbackground",
- "mathcolor", "mathvariant", "mathvariant", "maxsize", "minsize", "other",
- "rowalign", "rowalign", "rowalign", "rowlines", "rowspacing", "rowspan",
- "rspace", "scriptlevel", "selection", "separator", "stretchy", "width",
- "width", "xlink:href", "xlink:show", "xlink:type", "xmlns", "xmlns:xlink"
- ));
-
-
- protected java.util.Set<String> svgAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "accent-height", "accumulate", "additive", "alphabetic", "arabic-form",
- "ascent", "attributeName", "attributeType", "baseProfile", "bbox", "begin",
- "by", "calcMode", "cap-height", "class", "color", "color-rendering",
- "content", "cx", "cy", "d", "descent", "display", "dur", "dx", "dy", "end",
- "fill", "fill-rule", "font-family", "font-size", "font-stretch",
- "font-style", "font-variant", "font-weight", "from", "fx", "fy", "g1", "g2",
- "glyph-name", "gradientUnits", "hanging", "height", "horiz-adv-x",
- "horiz-origin-x", "id", "ideographic", "k", "keyPoints", "keySplines",
- "keyTimes", "lang", "marker-end", "marker-mid", "marker-start",
- "markerHeight", "markerUnits", "markerWidth", "mathematical", "max", "min",
- "name", "offset", "opacity", "orient", "origin", "overline-position",
- "overline-thickness", "panose-1", "path", "pathLength", "points",
- "preserveAspectRatio", "r", "refX", "refY", "repeatCount", "repeatDur",
- "requiredExtensions", "requiredFeatures", "restart", "rotate", "rx", "ry",
- "slope", "stemh", "stemv", "stop-color", "stop-opacity",
- "strikethrough-position", "strikethrough-thickness", "stroke",
- "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
- "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage",
- "target", "text-anchor", "to", "transform", "type", "u1", "u2",
- "underline-position", "underline-thickness", "unicode", "unicode-range",
- "units-per-em", "values", "version", "viewBox", "visibility", "width",
- "widths", "x", "x-height", "x1", "x2", "xlink:actuate", "xlink:arcrole",
- "xlink:href", "xlink:role", "xlink:show", "xlink:title", "xlink:type",
- "xml:base", "xml:lang", "xml:space", "xmlns", "xmlns:xlink", "y", "y1", "y2",
- "zoomAndPan"
- ));
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_VALUE = java.util.regex.Pattern.compile(
- "^(#[0-9a-f]{3,6}|rgb\\(\\d{1,3}%?,\\d{1,3}%?,?\\d{1,3}%?\\)?|-?\\d{0,2}\\.?\\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\\))?)$"
- );
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_STRING1 = java.util.regex.Pattern.compile(
- "^([-:,;#%.\\sa-zA-Z0-9!]|\\w-\\w|'[\\s\\w]+'|\"[\\s\\w]+\"|\\([\\d,\\s]+\\))*$"
- );
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_STRING2 = java.util.regex.Pattern.compile(
- "^(\\s*[-\\w]+\\s*:\\s*[^:;]*(;|$))*$"
- );
-
-
- protected java.util.Set<String> styleProperties = new java.util.HashSet(java.util.Arrays.asList(
- "azimuth",
- "background", "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat",
- "border", "border-bottom", "border-bottom-color", "border-bottom-style",
- "border-bottom-width", "border-collapse", "border-color", "border-left",
- "border-left-color", "border-left-style", "border-left-width", "border-right",
- "border-right-color", "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width",
- "clear", "color",
- "cursor", "direction", "display", "elevation", "float", "font",
- "font-family", "font-size", "font-style", "font-variant", "font-weight",
- "height", "letter-spacing", "line-height",
- "margin", "margin-bottom", "margin-left", "margin-right", "margin-top",
- "max-height", "max-width", "min-height", "min-width",
- "overflow",
- "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
- "pause", "pause-after", "pause-before", "pitch",
- "pitch-range", "richness", "speak", "speak-header", "speak-numeral",
- "speak-punctuation", "speech-rate", "stress", "text-align",
- "text-decoration", "text-indent", "unicode-bidi", "vertical-align",
- "voice-family", "volume", "white-space", "width"
- ));
-
-
- protected java.util.Set<String> stylePropertiesValues = new java.util.HashSet(java.util.Arrays.asList(
- "aqua", "auto", "baseline", "black", "block", "blue", "bold", "both", "bottom", "brown",
- "center", "collapse", "dashed", "dotted", "fuchsia", "gray", "green",
- "inherit", "italic", "left", "length", "lime", "maroon", "medium", "middle", "navy", "none", "normal",
- "nowrap", "olive", "percentage", "pointer", "purple", "red", "right", "silver", "solid", "sub", "super",
- "teal", "text-bottom", "text-top", "top", "transparent", "underline", "white", "yellow"
- ));
-
- protected java.util.Set<String> svgStyleProperties = new java.util.HashSet(java.util.Arrays.asList(
- "fill", "fill-opacity", "fill-rule", "stroke", "stroke-linecap",
- "stroke-linejoin", "stroke-opacity", "stroke-width"
- ));
-
-
- public void validateLinkTagURI(Token element, String uri) throws SemanticException {
- if (!validateURI(uri)) {
- throw createSemanticException("Invalid URI", element);
- }
- }
-
- public void validateHtmlElement(Token element) throws SemanticException {
- String elementName = element.getText().toLowerCase();
- if (!acceptableElements.contains(elementName) &&
- !svgElements.contains(elementName) &&
- !mathmlElements.contains(elementName)) {
- throw createSemanticException(getInvalidElementMessage(elementName), element);
- }
- }
-
- public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException {
- String elementName = element.getText().toLowerCase();
- String attributeName = attribute.getText().toLowerCase();
- if (!acceptableAttributes.contains(attributeName) &&
- !svgAttributes.contains(attributeName) &&
- !mathmlAttributes.contains(attributeName)) {
- throw createSemanticException(getInvalidAttributeMessage(elementName, attributeName), element);
- }
-
- }
-
- public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException{
-
- if (attributeValue == null || attributeValue.length() == 0) return;
-
- String elementName = element.getText().toLowerCase();
- String attributeName = attribute.getText().toLowerCase();
-
- // Check element with attribute that has URI value (href, src, etc.)
- if (attributesWhoseValueIsAURI.contains(attributeName) && !validateURI(attributeValue)) {
- throw createSemanticException(getInvalidURIMessage(attributeValue), element);
- }
-
- // Check attribute value of style (CSS filtering)
- if (attributeName.equals("style")) {
- if (!REGEX_VALID_CSS_STRING1.matcher(attributeValue).matches() ||
- !REGEX_VALID_CSS_STRING2.matcher(attributeValue).matches()) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
-
- String[] cssProperties = attributeValue.split(";");
- for (String cssProperty : cssProperties) {
- if (!cssProperty.contains(":")) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
- String[] property = cssProperty.split(":");
- String propertyName = property[0].trim();
- String propertyValue = property.length == 2 ? property[1].trim() : null;
-
- // CSS property name
- if (!styleProperties.contains(propertyName) &&
- !svgStyleProperties.contains(propertyName)) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
-
- // CSS property value
- if (propertyValue != null && !stylePropertiesValues.contains(propertyValue)) {
- // Not in list, now check the regex
- if (!REGEX_VALID_CSS_VALUE.matcher(propertyValue).matches()) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
- }
- }
- }
-
-
- }
-
- public String getInvalidURIMessage(String uri){
- return "invalid URI";
- }
-
- public String getInvalidElementMessage(String elementName){
- return "invalid element '" + elementName + "'";
- }
-
- public String getInvalidAttributeMessage(String elementName, String attributeName){
- return "invalid attribute '" + attributeName + "' for element '" + elementName + "'";
- }
-
- public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value){
- return "invalid value of attribute '" + attributeName + "' for element '" + elementName + "'";
- }
-
- public void escapeSeamTextToken(Token element) {
- }
-
- protected boolean validateURI(String uri) {
-
- // Relative URI starts with a slash
- if (uri.startsWith("/")) return true;
-
- java.net.URI parsedURI;
- try {
- parsedURI = new java.net.URI(uri);
- } catch (java.net.URISyntaxException ex) {
- return false;
- }
-
- if (!uriSchemes.contains(parsedURI.getScheme())) {
- return false;
- }
- return true;
- }
-
- public SemanticException createSemanticException(String message, Token element) {
- return new SemanticException(
- message,
- element.getFilename(), element.getLine(), element.getColumn()
- );
- }
-
- }
-
-
- private final String SEAMTEXT_MONOSPACE = "|";
-
- private final String SEAMTEXT_TWIDDLE = "~";
-
- private final String SEAMTEXT_HASH = "#";
-
- private final String SEAMTEXT_HAT = "^";
-
- private final String SEAMTEXT_PLUS = "+";
-
- private final String SEAMTEXT_STAR = "*";
-
- private final String SEAMTEXT_UNDERSCORE = "_";
-
- private final String SEAMTEXT_EQ = "=";
-
- private final String SEAMTEXT_BACKTICK = "`";
-
- private final String SEAMTEXT_PARAGRAPH = "\n\n";
-
- private final String SEAM_DOUBLEQUOTE = "\"";
-
- private final String SEAM_OPEN = "[";
-
- private final String SEAM_CLOSE = "]";
-
- private final String SEAM_GT = ">";
-
-
- protected java.util.Set<String> seamTextSymbols = new java.util.HashSet(java.util.Arrays.asList(
- SEAMTEXT_MONOSPACE, SEAMTEXT_TWIDDLE, SEAMTEXT_HASH, SEAMTEXT_HAT, SEAMTEXT_PLUS, SEAMTEXT_STAR,
- SEAMTEXT_UNDERSCORE, SEAMTEXT_EQ, SEAMTEXT_BACKTICK, SEAMTEXT_PARAGRAPH, SEAM_DOUBLEQUOTE, SEAM_OPEN,
- SEAM_CLOSE, SEAM_GT
- ));
-
- protected java.util.Set<String> htmlSeamTextElements = new java.util.HashSet(java.util.Arrays.asList(
- "del", "sup", "pre","p", "q" ,"h1" ,"h2" ,"h3" ,"h4" ,"ul" ,"ol" ,"li" ,"i" ,"tt" ,"u" ,"a"));
-
- private Sanitizer sanitizer = new DefaultSanitizer();
-
- private java.util.Stack<Token> htmlElementStack = new java.util.Stack<Token>();
-
- private StringBuilder mainBuilder = new StringBuilder();
-
- private StringBuilder linkValueCollector = new StringBuilder();
-
- private String linkHolder;
-
- private StringBuilder builder = mainBuilder;
-
-
- public void setSanitizer(Sanitizer sanitizer) {
- this.sanitizer = sanitizer;
- }
-
- public String toString() {
- return builder.toString();
- }
-
- private void beginCapture() {
- builder = new StringBuilder();
- }
-
- private String endCapture() {
- String result = builder.toString();
- builder = mainBuilder;
- return result;
- }
-
- private void append(String... strings) {
- for (String string: strings) builder.append(string);
- }
-
-
- public boolean isLink(Token token) {
- String name = token.getText().toLowerCase();
- return "a".equals(name);
- }
-
- private String createSeamTextLink(String link, String value) {
-
- StringBuilder builder = new StringBuilder();
- builder.append("[");
-
- if (value != null) {
- builder.append(value.trim());
- }
-
- builder.append("=>");
- builder.append(link);
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public boolean isHeader(Token token) {
- String name = token.getText().toLowerCase();
- return ("h1".equals(name) || "h2".equals(name) || "h3".equals(name) || "h4".equals(name));
- }
-
- public String createSeamTextHeader(Token token) throws SemanticException {
-
- String name = token.getText();
- StringBuilder seamHeader = new StringBuilder();
-
- if("h1".equals(name)) {
- seamHeader.append("\n").append(SEAMTEXT_PLUS);
- } else if("h2".equals(name)) {
- seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
- } else if("h3".equals(name)) {
- seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
- } else if("h4".equals(name)) {
- seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
- }
-
- return seamHeader.toString();
- }
-
- public boolean isList(Token token){
- String name = token.getText();
- return ("ul".equals(name) || "ol".equals(name));
- }
-
- public boolean isListItem(Token token) {
- String name = token.getText().toLowerCase();
- return "li".equals(name);
- }
-
- public String createSeamTextList(Token token, java.util.Stack <Token> htmlElementStack) throws SemanticException {
- String seamText = null;
-
- Token parent = htmlElementStack.peek();
- String parentName = parent.getText().toLowerCase();
- if(parentName.equals("ul")) {
- seamText = SEAMTEXT_HASH;
- } else if (parentName.equals("ol")){
- seamText = SEAMTEXT_EQ;
- } else {
- String message = "<li> must follow <ol> or <ul> not <" + parent.getText() + ">";
- throw new SemanticException( message, parent.getFilename(), parent.getLine(), parent.getColumn());
- }
-
- return seamText != null ? seamText : "";
- }
-
- // validate lists and headers'
- public void validateNestedMarkup(Token name, java.util.Stack <Token> htmlElementStack) throws SemanticException {
- if(!htmlElementStack.isEmpty()) {
- for(Token token : htmlElementStack) {
-
- if(token.getText().equals("h1") || token.getText().equals("h2") || token.getText().equals("h3")
- || token.getText().equals("h4") || token.getText().equals("ol") || token.getText().equals("ul")) {
- String message = "<" + token.getText() + "> contains nested <" + name.getText() + "> token";
- throw new SemanticException( message, name.getFilename(), name.getLine(), name.getColumn());
- }
- }
- }
-
- }
-
- public void validateHeaderMarkup(Token token, java.util.Stack <Token> htmlElementStack) throws TokenStreamException, SemanticException{
- int EOF = 1;
- int ALPHANUMERICWORD = 4;
- int i = 0;
- int type;
-
- boolean containText = false;
-
- Token element = htmlElementStack.peek();
- String header = element.getText();
-
- if (header.equals("h1") || header.equals("h2") || header.equals("h3") || header.equals("h4")) {
- do {
- i++;
- type = LT(i).getType();
- if (type == ALPHANUMERICWORD) {
- containText = true;
- break;
- }
-
- } while ( type != EOF);
-
- if (!containText) {
- String message = "You must have some text following a heading";
- throw new SemanticException( message, element.getFilename(), element.getLine(), element.getColumn());
- }
- }
-
- }
-
- public String createSimpleSeamText(Token token) throws SemanticException{
-
- String name = token.getText().toLowerCase();
- StringBuilder seamText = new StringBuilder();
-
- if("tt".equals(name)) {
- seamText.append(SEAMTEXT_MONOSPACE);
- } else if("del".equals(name)) {
- seamText.append(SEAMTEXT_TWIDDLE);
- } else if("i".equals(name)) {
- seamText.append(SEAMTEXT_STAR);
- } else if("sup".equals(name)) {
- seamText.append(SEAMTEXT_HAT);
- } else if("u".equals(name)) {
- seamText.append(SEAMTEXT_UNDERSCORE);
- } else if("pre".equals(name)) {
- seamText.append(SEAMTEXT_BACKTICK);
- } else if("p".equals(name)) {
- seamText.append(SEAMTEXT_PARAGRAPH);
- } else if("q".equals(name)) {
- seamText.append(SEAM_DOUBLEQUOTE);
- } else if("blockquote".equals(name)) {
- seamText.append(SEAM_DOUBLEQUOTE);
- }
-
- return seamText.toString();
-
- }
-
- public boolean isSeamTextElement(Token element){
- String name = element.getText().toLowerCase();
- return htmlSeamTextElements.contains(name);
- }
-
-
- public String escapeSeamText(Token token, java.util.Stack <Token> parentHtmlTokens) throws TokenStreamException {
-
- StringBuilder result = new StringBuilder();
- String tokenName = token.getText();
-
- if(parentHtmlTokens != null && !parentHtmlTokens.isEmpty()){
- Token parentToken = parentHtmlTokens.peek();
- String parentTokenName = parentToken.getText().toLowerCase();
-
- if ("tt".equals(parentTokenName) || "pre".equals(parentTokenName)) {
-
- if ("<".equals(tokenName)) {
- result.append("<");
- } else if("&".equals(tokenName)) {
- result.append("&");
- } else if (">".equals(tokenName)) {
- result.append(">");
- } else if(""".equals(tokenName)){
- result.append("\"");
- }else if(seamTextSymbols.contains(tokenName)) {
- result.append(tokenName);
- }
- }
- }
- result = result.length() != 0 ? result : result.append("\\").append(tokenName);
- return result.toString();
- }
-
-
-
-}
-
-
-startRule: (newline)* (text eof)?
- ;
-
-text: ((seamCharacters|plain|html|htmlSpecialChars) (newline)*)+
- ;
-
-word: an:ALPHANUMERICWORD { append( an.getText() ); } | uc:UNICODEWORD { append( uc.getText() ); }
- ;
-
-htmlSpecialChars:
- DOUBLEQUOTE { append("\""); }
- | lt:ESCAPED_LT {append(escapeSeamText(lt, htmlElementStack));}
- | gt:ESCAPED_GT {append(escapeSeamText(gt, htmlElementStack));}
- | amp:ESCAPED_AMP {append(escapeSeamText(amp, htmlElementStack));}
- | qout:ESCAPED_QOUT {append(escapeSeamText(qout, htmlElementStack));}
-
- ;
-eof: EOF;
-
-punctuation: p:PUNCTUATION { append( p.getText() ); }
- | sq:SINGLEQUOTE { append( sq.getText() ); }
- | s:SLASH { append( s.getText() ); }
- ;
-
-specialChars:
- st:STAR {append( st.getText() ); }
- | b:BAR { append( b.getText() ); }
- | h:HAT { append( h.getText() ); }
- | p:PLUS { append( p.getText() ); }
- | eq:EQ { append( eq.getText() ); }
- | hh:HASH { append( hh.getText() ); }
- | e:ESCAPE { append( e.getText() ); }
- | t:TWIDDLE { append( t.getText() ); }
- | u:UNDERSCORE { append( u.getText() ); }
- ;
-
-
-seamCharacters:
- hat:HAT {append(escapeSeamText(hat, htmlElementStack));}
- | hash:HASH {append(escapeSeamText(hash, htmlElementStack));}
- | open:OPEN {append(escapeSeamText(open, htmlElementStack)) ;}
- | close:CLOSE {append(escapeSeamText(close, htmlElementStack));}
- | twiddle:TWIDDLE {append(escapeSeamText(twiddle, htmlElementStack));}
- | bar:BAR {append(escapeSeamText(bar, htmlElementStack));}
- | eq:EQ {append(escapeSeamText(eq, htmlElementStack));}
- | plus:PLUS {append(escapeSeamText(plus, htmlElementStack));}
- | backtick:BACKTICK {append(escapeSeamText(backtick, htmlElementStack));}
- | st:STAR {append(escapeSeamText(st, htmlElementStack));}
- | e:ESCAPE {append(escapeSeamText(e, htmlElementStack));}
- | gt:GT {append(escapeSeamText(gt, htmlElementStack));}
- ;
-
-space: s:SPACE {
-
- if(!htmlElementStack.isEmpty()) {
- String tokenName = htmlElementStack.peek().getText();
- if(!("ul".equals(tokenName) || "ol".equals(tokenName))) {
- append(s.getText());
- }
-
- } else {
- append(s.getText());
- }
-
- }
- ;
-
-newline: n:NEWLINE { append(n.getText());}
-
-
- ;
-
-newlineOrEof: newline | EOF
- ;
-
-html: openTag ( space | space attribute )* ( ( beforeBody body closeTagWithBody ) | closeTagWithNoBody)
- ;
-
-plain: (word|punctuation|space)
- ;
-
-body: (
-
- {
- Token token = htmlElementStack.peek();
- boolean isLink = isLink(token);
- linkValueCollector = new StringBuilder();
- }
- (
-
- seamCharacters|
-
-
- { if(isLink) {
- beginCapture();
- }
-
- }
- plain
- {
- if(isLink) {
- String plain = endCapture();
- linkValueCollector.append(plain);
- }
-
- }
-
- |html
- |htmlSpecialChars
- {
- if(isLink) {
- String message = "unexpected token";
- throw new SemanticException(message);
- }
- }
- |newline: NEWLINE )*)
- ;
-
-openTag:
- LT name:ALPHANUMERICWORD
- {
-
-
- sanitizer.validateHtmlElement(name);
-
- if (isSeamTextElement(name)) {
- if (isList(name)) {
- validateNestedMarkup(name, htmlElementStack);
- } else if (isListItem(name)) {
- append(createSeamTextList(name,htmlElementStack));
- } else if (isHeader(name)) {
- validateNestedMarkup(name, htmlElementStack);
- append(createSeamTextHeader(name));
- }
-
- } else {
- append("<");
- append(name.getText());
- }
- htmlElementStack.push(name);
-
- }
- ;
- exception
- catch [RecognitionException ex] {
- if (htmlElementStack.isEmpty()) throw ex;
- Token tok = htmlElementStack.peek();
- if (tok != null) {
- throw new HtmlRecognitionException(tok, ex);
- } else {
- throw ex;
- }
- }
-
-
-beforeBody: GT {
- Token name = htmlElementStack.peek();
- if(isSeamTextElement(name)){
- append(createSimpleSeamText(name));
- } else {
- append(">");
- }
- }
- ;
- exception
- catch [RecognitionException ex] {
- if (htmlElementStack.isEmpty()) throw ex;
- Token tok = htmlElementStack.peek();
- if (tok != null) {
- throw new HtmlRecognitionException(tok, ex);
- } else {
- throw ex;
- }
- }
-
-closeTagWithBody:
- LT SLASH name:ALPHANUMERICWORD GT
- {
- if(isSeamTextElement(name)){
- if(isLink(name)){
- append(createSeamTextLink(linkHolder,linkValueCollector.toString().trim()));
- } else {
- append(createSimpleSeamText(name));
- }
-
- if(isListItem(name) || isHeader(name)) {
- append("\n");
- validateHeaderMarkup(name,htmlElementStack);
- }
-
- } else {
- append("</");
- append(name.getText());
- append(">");
- }
-
-
- htmlElementStack.pop();
- }
- ;
-
-closeTagWithNoBody:
- SLASH GT
- { append("/>");
- htmlElementStack.pop();
- }
- ;
-
-attribute: att:ALPHANUMERICWORD (space)* EQ (space)*
- DOUBLEQUOTE
- {
- Token token = htmlElementStack.peek();
- sanitizer.validateHtmlAttribute(token, att);
- boolean isSeamTextProcessed = isSeamTextElement(token);
-
- if (!isSeamTextProcessed) {
- append(att.getText());
- append("=\"");
- }
- beginCapture();
- }
- attributeValue
- {
- String attValue = endCapture();
- sanitizer.validateHtmlAttributeValue(token, att, attValue);
-
- if (!isSeamTextProcessed) {
- append(attValue);
- } else if(isLink(token) && "href".equals(att.getText())) {
-
- linkHolder = attValue;
- }
-
- }
- DOUBLEQUOTE {
- if(!isSeamTextProcessed) {
- append("\"");
- }
- }
- ;
- exception
- catch [RecognitionException ex] {
- if (htmlElementStack.isEmpty()) throw ex;
- Token tok = htmlElementStack.peek();
- if (tok != null) {
- throw new HtmlRecognitionException(tok, ex);
- } else {
- throw ex;
- }
- }
-
-attributeValue: ( AMPERSAND { append("&"); } |
- an:ALPHANUMERICWORD { append( an.getText() ); } |
- p:PUNCTUATION { append( p.getText() ); } |
- s:SLASH { append( s.getText() ); } |
- space|specialChars )*
- ;
- exception
- catch [RecognitionException ex] {
- if (htmlElementStack.isEmpty()) throw ex;
- Token tok = htmlElementStack.peek();
- if (tok != null) {
- throw new HtmlRecognitionException(tok, ex);
- } else {
- throw ex;
- }
- }
-
-class HtmlSeamTextLexer extends Lexer;
-
-options
-{
- k=2;
-
- // Allow any char but \uFFFF (16 bit -1)
- charVocabulary='\u0000'..'\uFFFE';
-}
-
-
-// Unicode sets allowed:
-// '\u00a0'..'\u00ff' Latin 1 supplement (no control characters) http://www.unicode.org/charts/PDF/U0080.pdf
-// '\u0100'..'\u017f' Latin Extended A http://www.unicode.org/charts/PDF/U0100.pdf
-// '\u0180'..'\u024f' Latin Extended B http://www.unicode.org/charts/PDF/U0180.pdf
-// '\u0250'..'\ufaff' Various other languages, punctuation etc. (excluding "presentation forms")
-// '\uff00'..'\uffef' Halfwidth and Fullwidth forms (including CJK punctuation)
-
-ALPHANUMERICWORD
- options {
- paraphrase = "letters or digits";
- }
- : ('a'..'z'|'A'..'Z'|'0'..'9')+
- ;
-
-UNICODEWORD
- options {
- paraphrase = "letters or digits";
- }
- : (
- '\u00a0'..'\u00ff' |
- '\u0100'..'\u017f' |
- '\u0180'..'\u024f' |
- '\u0250'..'\ufaff' |
- '\uff00'..'\uffef'
- )+
- ;
-
-PUNCTUATION
- options {
- paraphrase = "a punctuation character";
- }
- : '-' | ';' | ':' | '(' | ')' | '{' | '}' | '?' | '!' | '@' | '%' | '.' | ',' | '$'
- ;
-
-EQ
- options {
- paraphrase = "an equals '='";
- }
- : '='
- ;
-
-PLUS
- options {
- paraphrase = "a plus '+'";
- }
- : '+'
- ;
-
-UNDERSCORE
- options {
- paraphrase = "an underscore '_'";
- }
- : '_'
- ;
-
-STAR
- options {
- paraphrase = "a star '*'";
- }
- : '*'
- ;
-
-SLASH
- options {
- paraphrase = "a slash '/'";
- }
-
- : '/'
- ;
-
-ESCAPE
- options {
- paraphrase = "the escaping blackslash '\'";
- }
- : '\\'
- ;
-
-BAR
- options {
- paraphrase = "a bar or pipe '|'";
- }
- : '|'
- ;
-
-BACKTICK
- options {
- paraphrase = "a backtick '`'";
- }
- : '`'
- ;
-
-
-TWIDDLE
- options {
- paraphrase = "a tilde '~'";
- }
- : '~'
- ;
-
-DOUBLEQUOTE
- options {
- paraphrase = "a doublequote \"";
- }
- : '"'
- ;
-
-SINGLEQUOTE
- options {
- paraphrase = "a single quote '";
- }
- : '\''
- ;
-
-OPEN
- options {
- paraphrase = "an opening square bracket '['";
- }
- : '['
- ;
-
-CLOSE
- options {
- paraphrase = "a closing square bracket ']'";
- }
- : ']'
- ;
-
-HASH
- options {
- paraphrase = "a hash '#'";
- }
- : '#'
- ;
-
-HAT
- options {
- paraphrase = "a caret '^'";
- }
- : '^'
- ;
-
-GT
- options {
- paraphrase = "a closing angle bracket '>'";
- }
- : '>'
- ;
-
-LT
- options {
- paraphrase = "an opening angle bracket '<'";
- }
- : '<'
- ;
-
-AMPERSAND
- options {
- paraphrase = "an ampersand '&'";
- }
- : '&'
- ;
-
-SPACE
- options {
- paraphrase = "a space or tab";
- }
- : (' '|'\t')+
- ;
-
-NEWLINE
- options {
- paraphrase = "a newline";
- }
- : "\r\n" | '\r' | '\n'
- ;
-
-EOF
- options {
- paraphrase = "the end of the text";
- }
- : '\uFFFF'
- ;
-
-ESCAPED_LT : "<"
- ;
-
-ESCAPED_GT : ">"
- ;
-
-ESCAPED_AMP : "&"
- ;
-
-ESCAPED_QOUT : """
- ;
-
-
-
-
-
-
-
-
-
15 years, 6 months
JBoss Rich Faces SVN: r11008 - trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable.
by richfaces-svn-commits@lists.jboss.org
Author: piotr.buda
Date: 2008-11-04 06:27:53 -0500 (Tue, 04 Nov 2008)
New Revision: 11008
Modified:
trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
Log:
Resizable columns fixed for IE7 (bug with window resize #RF-4528)
Modified: trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
--- trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-04 11:21:36 UTC (rev 11007)
+++ trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-04 11:27:53 UTC (rev 11008)
@@ -302,6 +302,8 @@
getScrollbarWidth: function() {
var sd = this.scrollingDiv.getElement();
+ LOG.debug("Scrolling Div offsetWidth: " + sd.offsetWidth);
+ LOG.debug("Scrolling Div clientWidth: " + sd.clientWidth);
return sd.offsetWidth - sd.clientWidth;
},
validateColumnsWidth: function(columns,excessWidth) {
@@ -394,6 +396,7 @@
newHeight -= this.header.getCaptionHeight();
scrollingDiv.setStyle('height:'+ newHeight +'px;');
header.adjustSeparators();
+ this.saveRatios();
this.hideSplashScreen();
},
@@ -403,8 +406,14 @@
saveRatios: function() {
LOG.debug('saveRatios');
var c = this.getColumns(); //table columns
- var scrollbarWidth = this.getScrollbarWidth(); //width of the scrollbar
- LOG.debug('Scrollbar: ' + scrollbarWidth);
+ var scrollbarWidth;
+ if(!this._scrollbarWidth) {
+ scrollbarWidth = this.getScrollbarWidth(); //width of the scrollbar
+ LOG.debug('Scrollbar: ' + scrollbarWidth);
+ } else {
+ scrollbarWidth = this._scrollbarWidth;
+ LOG.debug('Scrollbar (cache): ' + this._scrollbarWidth);
+ }
var mainDivWidth = this.mainDiv.getWidth(); //width of the whole div with table
LOG.debug('Main DIV: ' + mainDivWidth);
var maxWidth = mainDivWidth - scrollbarWidth; //max width of the table
@@ -425,6 +434,7 @@
LOG.debug('firing calculateWidthsFromRatios');
var c = this.getColumns(); //table columns
var scrollbarWidth = this.getScrollbarWidth(); //width of the scrollbar
+ this._scrollbarWidth = scrollbarWidth;
LOG.debug('Scrollbar: ' + scrollbarWidth);
var mainDivWidth = this.mainDiv.getWidth(); //width of the whole div with table
LOG.debug('Main DIV: ' + mainDivWidth);
15 years, 6 months
JBoss Rich Faces SVN: r11006 - trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable.
by richfaces-svn-commits@lists.jboss.org
Author: piotr.buda
Date: 2008-11-04 04:00:35 -0500 (Tue, 04 Nov 2008)
New Revision: 11006
Modified:
trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
Log:
Fixed resizing of columns when browser window is resized.
Modified: trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
--- trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-03 18:28:41 UTC (rev 11005)
+++ trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-04 09:00:35 UTC (rev 11006)
@@ -6,6 +6,7 @@
$(this.id).component = this;
this["rich:destructor"] = "destroy";
this.groups = [];
+ this.ratios = [];
// register event handlers
this.options = options;
@@ -19,7 +20,7 @@
if (this.options.onColumnResize != null){
this.onColumnResize = this.options.onColumnResize;
this.columnWidths = "";
- }
+ }
this.eventContainerResize = this.OnWindowResize.bindAsEventListener(this);
this.eventGroupRowClicked = this.OnGroupRowMouseClicked.bindAsEventListener(this);
Event.observe(window, "resize", this.eventContainerResize);
@@ -96,13 +97,14 @@
if (dS > 0) {
this.scrollingDiv.getElement().scrollTop = scrollTop + dS;
}
- }
+ }
},
setColumnWidth: function(columnIndex, newWidth) {
if (columnIndex >= this.getColumnsNumber) {
return false;
}else{
+ //TODO IE fails here, need to find a workaround
this.getColumns()[columnIndex].width = newWidth;
}
},
@@ -176,7 +178,9 @@
OnWindowResize: function(event) {
if (this.table) {
+ this.calculateWidthsFromRatios();
this.updateLayout();
+ //this.correctColumns();
}
},
getColumnsNumber: function() {
@@ -264,7 +268,7 @@
this.splashScreen = $(this.id+":splashscreen");
this.mainDiv = new ClientUI.common.box.Box(this.id,null,true);
this.outerDiv = new ClientUI.common.box.Box(this.id +":od",null,true);
- this.tableB = $(this.id +":n")
+ this.tableB = $(this.id +":n");
this.fakeIeRow = $(this.id +":fakeIeRow");
this.fakeIeBodyRow = $(this.id +":body:fakeIeRow");
this.header = new ExtendedDataTable.DataTable.header(this.id +":header",this);
@@ -293,12 +297,15 @@
i++;
groupRow = $(id+':group-row:'+i);
}
+ this.saveRatios();
},
+
getScrollbarWidth: function() {
var sd = this.scrollingDiv.getElement();
return sd.offsetWidth - sd.clientWidth;
},
validateColumnsWidth: function(columns,excessWidth) {
+ LOG.debug('firing validateColumnsWidth');
var i=0;
var endIndex = columns.length-1;
while ((i < endIndex) && (excessWidth > 0)) {
@@ -358,40 +365,91 @@
var columnsNumber = this.getColumnsNumber();
var visibleHeaderWidth = this.header.getVisibleWidth();
- var scrollbarWidth = scrollingDiv.getElement().offsetWidth - scrollingDiv.getElement().clientWidth;
+ //var scrollbarWidth = scrollingDiv.getElement().offsetWidth - scrollingDiv.getElement().clientWidth;
+ var scrollbarWidth = this.getScrollbarWidth();
var maxAllowedWidth = mainDivWidth - scrollbarWidth;
for (var i=0; i < columnsNumber-1; i++) {
if (this.header.isColumnWidthPercentage(i)) {
//change percents into pixels
- var val = this.header.getColumn(i).width;
- val = (val.substr(0, val.length-1)*1)/100;
- var width = maxAllowedWidth*val;
+ var width = this._percentsToPixels(this.header.getColumn(i).width, maxAllowedWidth);
this.header.setColumnWidth(i, width);
this.setColumnWidth(i, width);
}
+ var headerChild = headerChildren[i];
+ Utils.DOM.Event.removeListeners(headerChild);
+ Utils.DOM.Event.observe(headerChild,'mouseover',this.header.eventHeaderCellMouseOver);
+ Utils.DOM.Event.observe(headerChild,'mouseout',this.header.eventHeaderCellMouseOut);
+ var isSortable = headerChild.getAttribute('sortable');
+ if ((isSortable) && (isSortable.indexOf('true') == 0)) {
+ Utils.DOM.Event.observe(headerChild, 'click', this.eventCellClicked);
+ }
}
- var excessWidth = this.header.getVisibleWidth() - maxAllowedWidth - 1;
- if (excessWidth > 0) {
- this.validateColumnsWidth(cols,excessWidth);
- };
+ //var excessWidth = this.header.getVisibleWidth() - maxAllowedWidth - 1;
+ //if (excessWidth > 0) {
+ // this.validateColumnsWidth(cols,excessWidth);
+ //};
cols[columnsNumber-1].width = null;
cols[cols.length-1].width = null;
var newHeight = mainDivHeight - header.getHeight() - footerHeight - 2;
newHeight -= this.header.getCaptionHeight();
scrollingDiv.setStyle('height:'+ newHeight +'px;');
- for (var i=0; i < columnsNumber-1; i++) {
- var headerChild = headerChildren[i];
- Utils.DOM.Event.removeListeners(headerChild);
- Utils.DOM.Event.observe(headerChild,'mouseover',this.header.eventHeaderCellMouseOver);
- Utils.DOM.Event.observe(headerChild,'mouseout',this.header.eventHeaderCellMouseOut);
- var isSortable = headerChild.getAttribute('sortable');
- if ((isSortable) && (isSortable.indexOf('true') == 0)) {
- Utils.DOM.Event.observe(headerChild, 'click', this.eventCellClicked);
- }
- };
header.adjustSeparators();
this.hideSplashScreen();
},
+
+ /**
+ * Calculates ratios of column width to total table width.
+ */
+ saveRatios: function() {
+ LOG.debug('saveRatios');
+ var c = this.getColumns(); //table columns
+ var scrollbarWidth = this.getScrollbarWidth(); //width of the scrollbar
+ LOG.debug('Scrollbar: ' + scrollbarWidth);
+ var mainDivWidth = this.mainDiv.getWidth(); //width of the whole div with table
+ LOG.debug('Main DIV: ' + mainDivWidth);
+ var maxWidth = mainDivWidth - scrollbarWidth; //max width of the table
+ LOG.debug('Width to spread: ' + maxWidth);
+ //generate ratio for each column
+ for(i = 0;i < c.length - 1;i++) {
+ var w = c[i].width;
+ if(this.header.isColumnWidthPercentage(i)) {//width in percents
+ //convert to pixels
+ w = this._percentsToPixels(w, maxWidth);
+ }
+ this.ratios[i] = w / maxWidth;
+ LOG.debug('Column[' + i + '] ratio: ' + this.ratios[i]);
+ }
+ },
+
+ calculateWidthsFromRatios: function() {
+ LOG.debug('firing calculateWidthsFromRatios');
+ var c = this.getColumns(); //table columns
+ var scrollbarWidth = this.getScrollbarWidth(); //width of the scrollbar
+ LOG.debug('Scrollbar: ' + scrollbarWidth);
+ var mainDivWidth = this.mainDiv.getWidth(); //width of the whole div with table
+ LOG.debug('Main DIV: ' + mainDivWidth);
+ var maxWidth = mainDivWidth - scrollbarWidth; //max width of the table
+ LOG.debug('Width to spread: ' + maxWidth);
+ var totalWidth = 0;
+ //set widths according to each column's width ratio
+ for(i = 0;i < c.length - 1;i++) {
+ LOG.debug('Column[' + i + '] ratio: ' + this.ratios[i]);
+ var w = Math.round(this.ratios[i] * maxWidth);
+ if(w < parseInt(this.minColumnWidth)) {
+ w = parseInt(this.minColumnWidth);
+ }
+ LOG.debug('setting column ' + i + ' to width: ' + w);
+ this.setColumnWidth(i, w);
+ this.header.setColumnWidth(i, w);
+ totalWidth += w;
+ }
+ //Compensate for rounding inaccuracy
+ if(totalWidth > maxWidth) {
+ //reduce width of the last column
+ c[c.length - 2].width -= (totalWidth - maxWidth);
+ }
+ },
+
update: function(refreshEvents) {
this.createControls();
if ( !ClientUILib.isIE ) {
@@ -407,6 +465,11 @@
this.selectionManager.refreshEvents();
this.updateLayout();
this.selectionManager.restoreState();
+ },
+
+ _percentsToPixels: function(percents, maxAllowedWidth) {
+ var val = (percents.substr(0, percents.length-1)*1)/100;
+ return maxAllowedWidth*val;
}
});
\ No newline at end of file
15 years, 6 months
JBoss Rich Faces SVN: r11005 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2008-11-03 13:28:41 -0500 (Mon, 03 Nov 2008)
New Revision: 11005
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
Log:
RF-3986:"oncomplete" documentation in richfaces_userguide.pdf wrong
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-11-03 17:57:41 UTC (rev 11004)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFCarchitectover.xml 2008-11-03 18:28:41 UTC (rev 11005)
@@ -592,14 +592,12 @@
also. </para>
<para>
<emphasis>
- <property>"oncomplete"</property>
- </emphasis> attribute allows to invoke the JavaScript code right after the Ajax
- Response is returned back and the DOM tree of the browser is updated. RichFaces
- registers the code for further invocation of XMLHTTP request object before an Ajax
- request is sent. This means the code will not be changed during processing of the
- request on the server if you use JSF EL value binding. Also, you cannot use
- "this'" inside the code, because it will not point the component
- where Ajax request was initiated. </para>
+ The <property>"oncomplete"</property>
+ </emphasis> attribute is used for passing JavaScript
+ that would be invoked right after the AJAX response returns back and DOM is updated.
+ It is not recommended to use use keyword <code>this</code> inside the EL-expression,
+ because it will not always point to the component where AJAX request was initiated.
+ </para>
<para>
<emphasis>
15 years, 6 months
JBoss Rich Faces SVN: r11004 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-11-03 12:57:41 -0500 (Mon, 03 Nov 2008)
New Revision: 11004
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
Log:
RF-4838
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-03 17:11:23 UTC (rev 11003)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-03 17:57:41 UTC (rev 11004)
@@ -27,6 +27,9 @@
import org.testng.annotations.Test;
public class OrderingListTest extends SeleniumTestBase {
+
+ private String orderingListId;
+
private String firstButton;
private String firstButtonDisabled;
@@ -57,7 +60,17 @@
private String activeItemText;
+ /**
+ * Check "caption" facet
+ */
@Test
+ public void testCaptionFacet(Template template) {
+ renderPage(template);
+ initFields();
+ Assert.assertEquals(selenium.getText("xpath=id('" + orderingListId + "table')/tbody/tr[1]"), "Caption Faset");
+ }
+
+ @Test
public void testButtons(Template template) {
renderPage(template);
initFields();
@@ -174,28 +187,28 @@
}
private void initFields() {
- String parentId = getParentId() + "_form:orderingList";
+ orderingListId = getParentId() + "_form:orderingList";
- firstButton = parentId + "first";
- firstButtonDisabled = parentId + "disfirst";
+ firstButton = orderingListId + "first";
+ firstButtonDisabled = orderingListId + "disfirst";
- upButton = parentId + "up";
- upButtonDisabled = parentId + "disup";
+ upButton = orderingListId + "up";
+ upButtonDisabled = orderingListId + "disup";
- downButton = parentId + "down";
- downButtonDisabled = parentId + "disdown";
+ downButton = orderingListId + "down";
+ downButtonDisabled = orderingListId + "disdown";
- lastButton = parentId + "last";
- lastButtonDisabled = parentId + "dislast";
+ lastButton = orderingListId + "last";
+ lastButtonDisabled = orderingListId + "dislast";
- firstRow = parentId + ":0";
- thirdRow = parentId + ":2";
+ firstRow = orderingListId + ":0";
+ thirdRow = orderingListId + ":2";
actionResultText = getParentId() + "_form:actionResult";
selectionText = getParentId() + "_form:selection";
activeItemText = getParentId() + "_form:activeItem";
ajax = firstRow + ":_ajax";
- server = parentId + ":1:_server";
+ server = orderingListId + ":1:_server";
}
public String getTestUrl() {
15 years, 6 months
JBoss Rich Faces SVN: r11003 - drafts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2008-11-03 12:11:23 -0500 (Mon, 03 Nov 2008)
New Revision: 11003
Added:
management/design/photosite/views drafts/FileUpload View.jpg
management/design/photosite/views drafts/User Pictures browse (List).jpg
management/design/photosite/views drafts/User pictures browse (Slideshow).jpg
management/design/photosite/views drafts/login preferences.jpg
management/design/photosite/views drafts/login.jpg
management/design/photosite/views drafts/main template after login.jpg
management/design/photosite/views drafts/user preferences.jpg
Removed:
management/design/photosite/views drafts/FileUpload View.vsd
management/design/photosite/views drafts/User Pictures browse (List).vsd
management/design/photosite/views drafts/User pictures browse (Slideshow).vsd
management/design/photosite/views drafts/login preferences.vsd
management/design/photosite/views drafts/login.vsd
management/design/photosite/views drafts/main template after login.vsd
management/design/photosite/views drafts/user preferences.vsd
Log:
Added: management/design/photosite/views drafts/FileUpload View.jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/FileUpload View.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/FileUpload View.vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/User Pictures browse (List).jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/User Pictures browse (List).jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/User Pictures browse (List).vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/User pictures browse (Slideshow).jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/User pictures browse (Slideshow).jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/User pictures browse (Slideshow).vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/login preferences.jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/login preferences.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/login preferences.vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/login.jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/login.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/login.vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/main template after login.jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/main template after login.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/main template after login.vsd
===================================================================
(Binary files differ)
Added: management/design/photosite/views drafts/user preferences.jpg
===================================================================
(Binary files differ)
Property changes on: management/design/photosite/views drafts/user preferences.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: management/design/photosite/views drafts/user preferences.vsd
===================================================================
(Binary files differ)
15 years, 6 months
JBoss Rich Faces SVN: r11002 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/contextMenu and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2008-11-03 10:21:44 -0500 (Mon, 03 Nov 2008)
New Revision: 11002
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenuAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ContextMenuTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenu.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ContextMenuTest.java
Log:
ContextMenu test
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ContextMenuTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ContextMenuTestBean.java 2008-11-03 12:53:13 UTC (rev 11001)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ContextMenuTestBean.java 2008-11-03 15:21:44 UTC (rev 11002)
@@ -21,13 +21,20 @@
package org.ajax4jsf.bean;
+import java.util.Date;
+
import javax.faces.event.ActionEvent;
public class ContextMenuTestBean {
+
+ static final String attachTo = "attachToLink";
+ String status;
private String value;
private int value2;
-
+ private String submitMode = "none";
+ private Boolean attached = false;
+ private String attacheTo = "";
public ContextMenuTestBean() {
value = "";
@@ -35,9 +42,33 @@
}
public void actionListener(ActionEvent event) {
- this.value = event.getComponent().getId();
+ status = "ActionListener";
}
+ public String testServerSubmitMode() {
+ submitMode = "server";
+ status = null;
+ return null;
+ }
+
+ public String testAjaxSubmitMode() {
+ submitMode = "ajax";
+ status = null;
+ return null;
+ }
+
+ public String testAttached() {
+ attached = true;
+ attacheTo = null;
+ return null;
+ }
+
+ public String testAttachTo() {
+ attacheTo = attachTo;
+ attached = true;
+ return null;
+ }
+
public String getValue() {
return value;
}
@@ -45,9 +76,9 @@
public void setValue(String value) {
this.value = value;
}
-
+
public String action() {
- if (4 == value2 ) {
+ if (4 == value2) {
value2 = 1;
} else {
value2++;
@@ -55,6 +86,17 @@
return null;
}
+ public String getTime() {
+ return String.valueOf(new Date().getTime());
+ }
+
+ public void reset() {
+ submitMode = "none";
+ attached = false;
+ attacheTo = "";
+ status = null;
+ }
+
public int getValue2() {
return value2;
}
@@ -62,14 +104,70 @@
public void setValue2(int value2) {
this.value2 = value2;
}
-
+
public String getMessage3() {
return "Menu3";
}
-
+
public String getMessage4() {
return "Menu4";
}
+ /**
+ * @return the submitMode
+ */
+ public String getSubmitMode() {
+ return submitMode;
+ }
+ /**
+ * @param submitMode
+ * the submitMode to set
+ */
+ public void setSubmitMode(String submitMode) {
+ this.submitMode = submitMode;
+ }
+
+ /**
+ * @return the attached
+ */
+ public Boolean getAttached() {
+ return attached;
+ }
+
+ /**
+ * @param attached the attached to set
+ */
+ public void setAttached(Boolean attached) {
+ this.attached = attached;
+ }
+
+ /**
+ * @return the attacheTo
+ */
+ public String getAttacheTo() {
+ return attacheTo;
+ }
+
+ /**
+ * @param attacheTo the attacheTo to set
+ */
+ public void setAttacheTo(String attacheTo) {
+ this.attacheTo = attacheTo;
+ }
+
+ /**
+ * @return the status
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status the status to set
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenu.xhtml
===================================================================
(Binary files differ)
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenuAutoTest.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenuAutoTest.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/contextMenu/contextMenuAutoTest.xhtml 2008-11-03 15:21:44 UTC (rev 11002)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <rich:contextMenu id="componentId"
+ immediate="#{autoTestBean.immediate}"
+ ajaxSingle="#{autoTestBean.ajaxSingle}"
+ reRender="#{autoTestBean.reRender}"
+ limitToList="#{autoTestBean.limitToList}"
+ bypassUpdates="#{autoTestBean.bypassUpdate}"
+ rendered="#{autoTestBean.rendered}"
+ oncomplete="#{autoTestBean.oncomplete}"
+ submitMode="#{contextMenuBean.submitMode}"
+ >
+ <rich:menuItem id="item1" actionListener="#{autoTestBean.actionListener}" value="Item1" />
+ <f:param name="parameter1" value="value1" />
+ </rich:contextMenu>
+ <a href="#" id="showMenu" onclick="$(getParentId() + 'autoTestForm:componentId').component.show(event)">Show</a>
+ <a href="#" onclick="$(getParentId() + 'autoTestForm:componentId').component.hide()">Hide</a>
+ </ui:define>
+ <ui:define name="customControls">
+ <h:form id="controls">
+ <h:commandButton id="testServerSubmit" action="#{contextMenuBean.testServerSubmitMode}" value="testServerSubmit"></h:commandButton>
+ <h:commandButton id="testAjaxSubmit" action="#{contextMenuBean.testAjaxSubmitMode}" value="testAjaxSubmit"></h:commandButton>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ContextMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ContextMenuTest.java 2008-11-03 12:53:13 UTC (rev 11001)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ContextMenuTest.java 2008-11-03 15:21:44 UTC (rev 11002)
@@ -27,10 +27,13 @@
import org.testng.annotations.Test;
public class ContextMenuTest extends SeleniumTestBase {
-
+
static final String FORMID = "_form:";
+ static final String CONTROL_FORMID = "_controls:";
static final String UNATTACHED_CONTEXTMENU = "contextMenu";
+ static final String RESET_METHOD = "#{contextMenuBean.reset}";
+
String linkShowId;
String linkHideId;
String componentControlShowLinkId;
@@ -38,7 +41,7 @@
String contextMenuId;
String autoCreatedId;
String contextMenuBody;
-
+
void initIds(String parentId, String contextMenuId) {
parentId = getParentId() + FORMID;
linkShowId = "showMenu";
@@ -48,38 +51,133 @@
contextMenuId = parentId + contextMenuId;
autoCreatedId = contextMenuId + ":_auto_created";
contextMenuBody = contextMenuId + "_menu";
+ this.contextMenuId = contextMenuId;
}
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/contextMenu/contextMenuAutoTest.xhtml";
+ }
+
+
@Test
+ public void testActionListener(Template template) {
+ renderPage(template, RESET_METHOD);
+ initIds(getParentId(), UNATTACHED_CONTEXTMENU);
+ String statusId = getParentId() + FORMID + "status";
+
+ clickById(linkShowId);
+ waitForMenuShow(contextMenuId);
+ String itemId = getParentId() + FORMID + "item2";
+ clickById(itemId);
+ pause(200, contextMenuId);
+ AssertTextEquals(statusId, "", "No action listener should be passed for submitMode = none");
+
+ String controlId = getParentId() + CONTROL_FORMID + "testServerMode";
+ clickCommandAndWait(controlId);
+ clickById(linkShowId);
+ waitForMenuShow(contextMenuId);
+ clickCommandAndWait(itemId);
+ AssertTextEquals(statusId, "ActionListener", "Action listener skipped for SubmitMode = server ");
+
+ controlId = getParentId() + CONTROL_FORMID + "testAjaxMode";
+ clickCommandAndWait(controlId);
+ clickById(linkShowId);
+ waitForMenuShow(contextMenuId);
+ clickAjaxCommandAndWait(itemId);
+ AssertTextEquals(statusId, "ActionListener", "Action listener skipped for SubmitMode = ajax ");
+
+ }
+
+ @Test
+ public void testAttachedAndAttachedTo(Template template) {
+ renderPage(template, RESET_METHOD);
+ initIds(getParentId(), UNATTACHED_CONTEXTMENU);
+
+ String controlId = getParentId() + CONTROL_FORMID + "testAttached";
+ clickCommandAndWait(controlId);
+
+ String attachedLink = getParentId() + FORMID + "parentLink";
+ clickById(attachedLink);
+ waitForMenuShow(contextMenuId, "Attached = true does not work");
+ AssertPresent(contextMenuBody, "Context menu has not been shown");
+
+
+ controlId = getParentId() + CONTROL_FORMID + "testAttachTo";
+ clickCommandAndWait(controlId);
+
+ String attachedTo = "attachToLink";
+ clickById(attachedTo);
+ waitForMenuShow(contextMenuId, "AttachTo does not work");
+ AssertPresent(contextMenuBody, "Context menu has not been shown");
+ }
+
+ @Test
+ public void testSubmitMode(Template template) {
+ renderPage(template, RESET_METHOD);
+ initIds(getParentId(), UNATTACHED_CONTEXTMENU);
+
+ String controlId = getParentId() + CONTROL_FORMID + "testServerMode";
+ String timeId = getParentId() + FORMID + "time";
+ String time = getTextById(timeId);
+ String itemId = getParentId() + FORMID + "item1";
+
+ writeStatus("Test server submit mode");
+ /** test server submit mode */
+ clickCommandAndWait(controlId);
+ clickById(linkShowId);
+ waitForMenuShow(contextMenuId);
+ clickById(itemId);
+ waitForPageToLoad();
+ AssertTextNotEquals(timeId, time, "Server submit mode does not work");
+
+ writeStatus("Test server submit mode");
+ /** test ajax submit mode */
+ controlId = getParentId() + CONTROL_FORMID + "testAjaxMode";
+ clickCommandAndWait(controlId);
+ time = getTextById(timeId);
+ clickById(linkShowId);
+ waitForMenuShow(contextMenuId);
+ clickAjaxCommandAndWait(itemId);
+ AssertTextNotEquals(timeId, time, "Ajax submit mode does not work");
+
+ }
+
+ @Test
public void testContextMenuRendering(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
String parentId = getParentId();
String menuId = parentId + FORMID + "contextMenu2";
String menuBody = menuId + "_menu";
String autoCreatedId = menuId + ":_auto_created";
-
+
String showId = "showContext2";
String hideId = "hideContext2";
-
- //show menu
+
+ // show menu
clickById(showId);
-
+
waitForMenuShow(menuId);
-
+
AssertPresent(menuBody, "Context menu has not been displayed");
AssertPresent(autoCreatedId, "Context menu has not been displayed");
-
+
String menuGroupId = parentId + FORMID + "menuGroup";
String itemId = parentId + FORMID + "g5";
AssertPresent(menuGroupId, "Context menu group has not been displayed");
AssertPresent(itemId, "Menu item has not been displayed");
- int separatorCount = selenium.getXpathCount("//div[@id='"+menuBody+"']/div/div[@class='dr-menu-separator rich-menu-separator']").intValue();
+ int separatorCount = selenium
+ .getXpathCount(
+ "//div[@id='"
+ + menuBody
+ + "']/div/div[@class='dr-menu-separator rich-menu-separator']")
+ .intValue();
Assert.assertTrue(separatorCount == 1, "Separators count is invalid");
-
+
menuBody = parentId + FORMID + "menuGroup_menu";
-
+
AssertPresent(menuBody);
itemId = parentId + FORMID + "g1";
AssertTextEquals(itemId, "Item1", "Item label is invalid");
@@ -92,163 +190,117 @@
itemId = parentId + FORMID + "g4";
AssertTextEquals(itemId, "Item3", "Item label is invalid");
AssertPresent(itemId, "Menu item has not been displayed");
-
- separatorCount = selenium.getXpathCount("//div[@id='"+menuBody+"']/div/div[@class='dr-menu-separator rich-menu-separator']").intValue();
+
+ separatorCount = selenium
+ .getXpathCount(
+ "//div[@id='"
+ + menuBody
+ + "']/div/div[@class='dr-menu-separator rich-menu-separator']")
+ .intValue();
Assert.assertTrue(separatorCount == 1, "Separators count is invalid");
-
+
clickById(hideId);
clickById(showId);
-
+
menuId = parentId + FORMID + "menuGroup";
fireMouseEvent(menuId, "mouseover", 10, 10, false);
waitForMenuShow(menuId);
-
+
String top = runScript(getElementById(menuBody) + ".style.top");
String left = runScript(getElementById(menuBody) + ".style.left");
-
+
Assert.assertTrue(top != null && top.length() > 0);
Assert.assertTrue(left != null && left.length() > 0);
-
+
AssertTextEquals(menuId, "Group1", "Group label is invalid");
-
-
+
}
-
+
private void waitForMenuShow(String id) {
String bodyId = id + "_menu";
if (!selenium.isElementPresent(bodyId)) {
waiteForCondition(getElementById(bodyId), 5000);
}
- waiteForCondition(getElementById(bodyId) + ".style.display != 'none'", 5000);
+ waiteForCondition(getElementById(bodyId) + ".style.display != 'none'",
+ 5000);
}
-
-
- //@Test
+
+ private void waitForMenuShow(String id, String message) {
+ try {
+ waitForMenuShow(id);
+ } catch (Exception e) {
+ Assert.fail(message + e.getMessage());
+ }
+ }
+
+ @Test
public void testContextMenuStandAlone(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
initIds(getParentId(), UNATTACHED_CONTEXTMENU);
-
+
String menuItemId = getParentId() + FORMID + "item2";
-
+
AssertNotPresent(menuItemId, "Context menu should be hidden");
AssertNotPresent(autoCreatedId, "Context menu should be hidden");
-
+
clickById(linkShowId);
-
+
AssertPresent(menuItemId, "Context menu has not been shown");
AssertPresent(autoCreatedId, "Context menu has not been shown");
- AssertTextEquals(menuItemId, "Menu2", "Context menu displays incorrect.");
-
+ AssertTextEquals(menuItemId, "Menu2",
+ "Context menu displays incorrect.");
+
clickById(linkHideId);
-
+
AssertNotVisible(contextMenuBody, "Context menu has not been hidden");
}
-
- //@Test
+
+ @Test
public void testComponentControlManagement(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
initIds(getParentId(), UNATTACHED_CONTEXTMENU);
-
+
String menuItemId = getParentId() + FORMID + "item2";
-
AssertNotPresent(menuItemId, "Context menu should be hidden");
AssertNotPresent(autoCreatedId, "Context menu should be hidden");
-
+
clickById(componentControlShowLinkId);
-
+
AssertPresent(menuItemId, "Context menu has not been shown");
AssertPresent(autoCreatedId, "Context menu has not been shown");
- AssertTextEquals(menuItemId, "Menu2", "Context menu displays incorrect.");
-
+ AssertTextEquals(menuItemId, "Menu2",
+ "Context menu displays incorrect.");
+
clickById(componentControlHideLinkId);
-
+
AssertNotVisible(contextMenuBody, "Context menu has not been hidden");
}
-
- //@Test
+
+ @Test
public void testMacrodefinitions(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
initIds(getParentId(), UNATTACHED_CONTEXTMENU);
String menuItemId = getParentId() + FORMID + "item1";
-
+
clickById(linkShowId);
-
- AssertTextEquals(menuItemId, "Menu1", "Macrosubstitution does not work.");
-
+
+ AssertTextEquals(menuItemId, "Menu1",
+ "Macrosubstitution does not work.");
+
clickById(componentControlShowLinkId);
menuItemId = getParentId() + FORMID + "item3";
- AssertTextEquals(menuItemId, "Menu3", "Macrosubstitution does not work.");
+ AssertTextEquals(menuItemId, "Menu3",
+ "Macrosubstitution does not work.");
menuItemId = getParentId() + FORMID + "item4";
- AssertTextEquals(menuItemId, "Menu4", "Macrosubstitution does not work.");
-
+ AssertTextEquals(menuItemId, "Menu4",
+ "Macrosubstitution does not work.");
+
}
- //@Test
- public void testContextMenuComponent(Template template) {
- renderPage(template);
+ public String getTestUrl() {
+ return "pages/contextMenu/contextMenu.xhtml";
+ }
- String parentId = getParentId() + "_form:";
- String inputId = parentId + "input";
- String input2Id = parentId + "input2";
- String outputId = parentId + "_value2";
- String menuId = parentId + "menu_input_menu";
- String menu2Id = parentId + "menu_input2_menu";
-
- String menu1_item_ajax = parentId + "menu1_item1";
- String menu1_item_server = parentId + "menu1_item2";
- String menu2_item_ajax = parentId + "menu2_item1";
- String menu2_item_server = parentId + "menu2_item2";
-
- writeStatus("Click on first input");
- clickById(inputId);
- antifast(menuId);
- Assert.assertTrue(isVisibleById(menuId));
-
- writeStatus("Click on second input");
- clickById(input2Id);
- antifast(menu2Id);
- Assert.assertFalse(isVisibleById(menuId));
- Assert.assertTrue(isVisibleById(menu2Id));
-
- writeStatus("Click on first input again");
- clickById(inputId);
- antifast(menuId);
- Assert.assertTrue(isVisibleById(menuId));
- Assert.assertFalse(isVisibleById(menu2Id));
-
- writeStatus("Click on ajax item in first menu");
- clickAjaxCommandAndWait(menu1_item_ajax);
- AssertValueEquals(inputId, "menu1_item1");
- AssertTextEquals(outputId, "1");
-
- writeStatus("Click on server item in first menu");
- clickCommandAndWait(menu1_item_server);
- AssertValueEquals(inputId, "menu1_item2");
- AssertTextEquals(outputId, "2");
-
- writeStatus("Click on second input again");
- clickById(input2Id);
- antifast(menu2Id);
- Assert.assertTrue(isVisibleById(menu2Id));
-
- writeStatus("Click on ajax item in first menu");
- clickAjaxCommandAndWait(menu2_item_ajax);
- AssertValueEquals(inputId, "menu2_item1");
- AssertTextEquals(outputId, "3");
-
- writeStatus("Click on server item in second menu");
- clickCommandAndWait(menu2_item_server);
- AssertValueEquals(inputId, "menu2_item2");
- AssertTextEquals(outputId, "4");
- }
-
- public String getTestUrl() {
- return "pages/contextMenu/contextMenu.xhtml";
- }
-
- private void antifast(String id) {
- waiteForCondition("document.getElementById('" + id + "') != undefined", 500);
- }
-
+
}
15 years, 6 months
JBoss Rich Faces SVN: r11001 - in trunk/test-applications/jsp/src/main: webapp/InputNumberSpinner and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: tromanovich
Date: 2008-11-03 07:53:13 -0500 (Mon, 03 Nov 2008)
New Revision: 11001
Modified:
trunk/test-applications/jsp/src/main/java/inputNumberSpinner/InputNumberSpinner.java
trunk/test-applications/jsp/src/main/webapp/InputNumberSpinner/InputNumberSpinner.jsp
Log:
add test of valueChangeListener for InputNumberSpinner
Modified: trunk/test-applications/jsp/src/main/java/inputNumberSpinner/InputNumberSpinner.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/inputNumberSpinner/InputNumberSpinner.java 2008-11-03 11:52:49 UTC (rev 11000)
+++ trunk/test-applications/jsp/src/main/java/inputNumberSpinner/InputNumberSpinner.java 2008-11-03 12:53:13 UTC (rev 11001)
@@ -1,5 +1,7 @@
package inputNumberSpinner;
+import javax.faces.event.ValueChangeEvent;
+
import org.richfaces.component.html.HtmlInputNumberSpinner;
import util.componentInfo.ComponentInfo;
@@ -22,6 +24,7 @@
private boolean manualInput;
private boolean rendered;
private HtmlInputNumberSpinner htmlInputNumberSpinner = null;
+ private String valueChangeListener;
public void addHtmlInputNumberSpinner(){
ComponentInfo info = ComponentInfo.getInstance();
@@ -44,6 +47,10 @@
inputStyle = null;
}
+
+ public void changeListener(ValueChangeEvent event) {
+ System.out.println("valueChangeListener " + event.toString());
+ }
public void doStyles() {
if (getStyle() == null) {
@@ -237,4 +244,13 @@
HtmlInputNumberSpinner htmlInputNumberSpinner) {
this.htmlInputNumberSpinner = htmlInputNumberSpinner;
}
+
+ public void valueChangeListener(ValueChangeEvent event) {
+ valueChangeListener = (String)event.getNewValue();
+ System.out.println("valueChangeListener: " + valueChangeListener);
+ }
+
+ public String getValueChangeListener() {
+ return valueChangeListener;
+ }
}
Modified: trunk/test-applications/jsp/src/main/webapp/InputNumberSpinner/InputNumberSpinner.jsp
===================================================================
--- trunk/test-applications/jsp/src/main/webapp/InputNumberSpinner/InputNumberSpinner.jsp 2008-11-03 11:52:49 UTC (rev 11000)
+++ trunk/test-applications/jsp/src/main/webapp/InputNumberSpinner/InputNumberSpinner.jsp 2008-11-03 12:53:13 UTC (rev 11001)
@@ -11,6 +11,7 @@
step="#{inputNumberSpinner.step}" rendered="#{inputNumberSpinner.rendered}" value="#{inputNumberSpinner.value}"
inputClass="#{style.inputClass}" styleClass="#{style.styleClass}" inputStyle="#{style.inputStyle}" style="#{style.style}"
enableManualInput="#{inputNumberSpinner.manualInput}" inputSize="#{inputNumberSpinner.inputSize}"
+ valueChangeListener="#{inputNumberSpinner.valueChangeListener}"
oninputmousedown="#{event.onmousedown}" onblur="#{event.onblur}"
onchange="#{event.onchange}" onclick="#{event.onclick}"
ondblclick="#{event.ondblclick}" onerror="#{event.onerror}"
@@ -22,5 +23,10 @@
onupclick="#{event.onupclick}"
accesskey="y">
</rich:inputNumberSpinner>
+
+ <h:panelGroup>
+ <a4j:commandButton value="valueChangeListener (show)" reRender="valueCLID" />
+ <h:outputText id="valueCLID" value=" #{inputNumberSpinner.valueChangeListener}" />
+ </h:panelGroup>
<rich:spacer height="20px"></rich:spacer>
</f:subview>
15 years, 6 months