Author: Alex.Kolonitsky
Date: 2009-05-29 07:22:12 -0400 (Fri, 29 May 2009)
New Revision: 14403
Modified:
branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx
Log:
Content between angle brackets is being stripped out from selected item of a suggestion
box
https://jira.jboss.org/jira/browse/RF-5599
Modified:
branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2009-05-28
17:46:49 UTC (rev 14402)
+++
branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2009-05-29
11:22:12 UTC (rev 14403)
@@ -127,26 +127,27 @@
private Pattern getTokensPattern(UIComponent component) {
//TODO nick - cache ?
- String tokens = (String) component.getAttributes().get("tokens");
+ String tokens = (String) component.getAttributes().get("tokens");
if (tokens != null && tokens.length() != 0) {
Pattern pattern;
+
synchronized (tokensCache) {
- pattern = tokensCache.get(tokens);
- if (pattern == null) {
- StringBuilder patternSource = new StringBuilder();
- char[] array = tokens.toCharArray();
- int l = array.length;
- for (int i = 0; i < l; i++) {
- if (i != 0) {
- patternSource.append('|');
- }
- patternSource.append(Pattern.quote(String.valueOf(array[i])));
- }
-
- pattern = Pattern.compile(patternSource.toString());
- tokensCache.put(tokens, pattern);
- }
- }
+ pattern = tokensCache.get(tokens);
+ if (pattern == null) {
+ StringBuilder patternSource = new StringBuilder();
+ char[] array = tokens.toCharArray();
+ int l = array.length;
+ for (int i = 0; i < l; i++) {
+ if (i != 0) {
+ patternSource.append('|');
+ }
+ patternSource.append(Pattern.quote(String.valueOf(array[i])));
+ }
+
+ pattern = Pattern.compile(patternSource.toString());
+ tokensCache.put(tokens, pattern);
+ }
+ }
return pattern;
} else {
@@ -241,13 +242,13 @@
UISuggestionBox suggestionBox = (UISuggestionBox) component;
if (!suggestionBox.isSubmitted()) {
suggestionBox.setRowIndex(-1);
+
writer.startElement(HTML.DIV_ELEM, component);
getUtils().encodeId(context, component);
- StringBuffer clazz = new StringBuffer(
- "rich-sb-common-container ");
- clazz.append(suggestionBox.getPopupClass() + " ").
- append(suggestionBox.getStyleClass());
+ StringBuffer clazz = new StringBuffer("rich-sb-common-container
");
+ clazz.append(suggestionBox.getPopupClass() + " ")
+ .append(suggestionBox.getStyleClass());
writer.writeAttribute("class", clazz, "popupClass");
int zIndex = suggestionBox.getZindex();
@@ -256,9 +257,9 @@
style.append(getSizeForStyle(component, "width", null, false));
style.append(getSizeForStyle(component, "height", null, false));
-
- style.append(suggestionBox.getPopupStyle() + ";").
- append(suggestionBox.getStyle() + ";");
+ style.append(suggestionBox.getPopupStyle() + ";")
+ .append(suggestionBox.getStyle() + ";");
+
writer.writeAttribute("style", style, "popupStyle");
UIComponent popupFacet = component.getFacet("popup");
@@ -281,21 +282,15 @@
writer.endElement(HTML.DIV_ELEM);
writer.startElement("iframe", component);
- writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif")
- .getUri(context, null), null);
- writer.writeAttribute("id", component.getClientId(context)
- + "_iframe", null);
- writer.writeAttribute(
- "style",
"position:absolute;display:none;z-index:" + zIndex + ";", null);
+ writer.writeAttribute("src",
getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context,
null), null);
+ writer.writeAttribute("id", component.getClientId(context) +
"_iframe", null);
+ writer.writeAttribute("style",
"position:absolute;display:none;z-index:" + zIndex + ";", null);
writer.endElement("iframe");
writer.startElement("input", component);
writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("id", component.getClientId(context)
- + "_selection", null);
- writer.writeAttribute("name", component.getClientId(context)
- + "_selection", null);
+ writer.writeAttribute("id", component.getClientId(context) +
"_selection", null);
+ writer.writeAttribute("name", component.getClientId(context) +
"_selection", null);
writer.endElement("input");
} else {
@@ -387,7 +382,7 @@
UIComponent targetComponent = getTarget(component);
String targetId = targetComponent.getClientId(context);
- Map attributes = component.getAttributes();
+ Map<String, Object> attributes = component.getAttributes();
StringBuffer script = new StringBuffer(" new ");
// Build ajax function call
JSFunction submitSuggest = AjaxRendererUtils.buildAjaxFunction(
@@ -395,7 +390,7 @@
submitSuggest.addParameter(targetId);
submitSuggest.addParameter(component.getClientId(context));
submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
component);
options.put("popup", component.getClientId(context));
for (int i = 0; i < OPTIONS.length; i++) {
String option = OPTIONS[i];
@@ -423,8 +418,7 @@
}
String onselect = (String) attributes.get("onselect");
if (null != onselect) {
- JSFunctionDefinition function = new JSFunctionDefinition(
- "suggestion");
+ JSFunctionDefinition function = new
JSFunctionDefinition("suggestion");
function.addParameter("event");
function.addToBody(onselect);
@@ -433,8 +427,7 @@
}
String onobjectchange = (String) attributes.get("onobjectchange");
if (null != onobjectchange) {
- JSFunctionDefinition function = new JSFunctionDefinition(
- "suggestion","event");
+ JSFunctionDefinition function = new
JSFunctionDefinition("suggestion","event");
function.addToBody(onobjectchange);
options.put("onobjectchange", function);
@@ -482,7 +475,7 @@
*/
private static class DataTemplateContext extends TemplateContext {
- private List columns;
+ private List<UIComponent> columns;
private int first;
@@ -516,8 +509,8 @@
this.putParameter("hasHead", Boolean.TRUE);
}
// Fill child columns components
- columns = new ArrayList(component.getChildCount());
- for (Iterator iter = component.getChildren().iterator(); iter
+ columns = new ArrayList<UIComponent>(component.getChildCount());
+ for (Iterator<UIComponent> iter = component.getChildren().iterator();
iter
.hasNext();) {
UIComponent column = (UIComponent) iter.next();
if (column instanceof UIColumn) {
@@ -881,15 +874,13 @@
final String endHtml = "</td></tr>";
UIComponent nothingLabelFacet = component.getFacet("nothingLabel");
- if(null != nothingLabelFacet && nothingLabelFacet.isRendered()) {
+ if (nothingLabelFacet != null && nothingLabelFacet.isRendered()) {
writer.write(startHtml);
renderChild(context, nothingLabelFacet);
writer.write(endHtml);
- }
- else {
+ } else {
String nothingLabel = suggestionBox.getNothingLabel();
- if (null != nothingLabel &&
- !"".equals(nothingLabel)) {
+ if (nothingLabel != null && !"".equals(nothingLabel)) {
writer.write(startHtml);
writer.write(nothingLabel);
writer.write(endHtml);
Modified:
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2009-05-28
17:46:49 UTC (rev 14402)
+++
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2009-05-29
11:22:12 UTC (rev 14403)
@@ -621,18 +621,30 @@
markPreviousPage: function() {
var pos = this.countVisibleEntries();
if (this.index > 0) {
- if (pos.current>0) this.index = this.index - Math.min(pos.current,pos.all);
- else this.index = this.index - pos.all;
- if (this.index < 0) this.index = 0;
+ if (pos.current>0) {
+ this.index = this.index - Math.min(pos.current,pos.all);
+ } else {
+ this.index = this.index - pos.all;
+ }
+
+ if (this.index < 0) {
+ this.index = 0;
+ }
}
},
markNextPage: function() {
var pos = this.countVisibleEntries();
if (this.index < this.entryCount - 1) {
- if ((pos.current < pos.all - 1) && pos.current>=0) this.index =
this.index + (pos.all - pos.current - 1);
- else this.index = this.index + pos.all;
- if (this.index > this.entryCount - 1) this.index = this.entryCount - 1;
+ if ((pos.current < pos.all - 1) && pos.current>=0) {
+ this.index = this.index + (pos.all - pos.current - 1);
+ } else {
+ this.index = this.index + pos.all;
+ }
+
+ if (this.index > this.entryCount - 1) {
+ this.index = this.entryCount - 1;
+ }
}
},
@@ -644,7 +656,9 @@
}*/
// optimization
var element = $(this.contentTable).firstChild;
- while (!element.tagName || element.tagName.toLowerCase()!="tbody")
element = element.nextSibling;
+ while (!element.tagName || element.tagName.toLowerCase()!="tbody") {
+ element = element.nextSibling;
+ }
return $(element.childNodes[index]);
},
Modified:
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx
===================================================================
---
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx 2009-05-28
17:46:49 UTC (rev 14402)
+++
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/table.jspx 2009-05-29
11:22:12 UTC (rev 14403)
@@ -27,7 +27,9 @@
</u:insertFacet>
<f:if context="hasColumnHead">
<u:insertChildren context="columns">
- <th nowrap="nowrap"><u:insertFacet
name="header"/></th>
+ <th nowrap="nowrap">
+ <u:insertFacet name="header"/>
+ </th>
</u:insertChildren>
</f:if>
</thead>
@@ -54,15 +56,19 @@
<f:call name="getEntryClass"/>
</f:attribute>
<f:if property="fetchValue">
- <td style="display: none;"><f:attribute
name="class"
-
property="selectValueClass"
-
mantadory="false"/> <f:verbatim
- property="fetchValue"/></td>
+ <td style="display: none;">
+ <f:attribute name="class"
property="selectValueClass" mantadory="false"/>
+ <f:verbatim property="fetchValue"
escape="true"/>
+ </td>
</f:if>
+
<u:insertChildren context="columns">
<td nowrap="nowrap"
class="rich-sb-cell-padding">
- <f:attribute name="style"><f:call
name="cellPadding"/></f:attribute>
- <u:insertChild/></td>
+ <f:attribute name="style">
+ <f:call name="cellPadding"/>
+ </f:attribute>
+ <u:insertChild/>
+ </td>
</u:insertChildren>
</tr>
</u:insertChildren>