You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/07/22 18:21:12 UTC
svn commit: r966728 - in /myfaces/tobago/trunk/tobago-theme:
tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/sta...
Author: lofwyr
Date: Thu Jul 22 16:21:11 2010
New Revision: 966728
URL: http://svn.apache.org/viewvc?rev=966728&view=rev
Log:
TOBAGO-881: ToolBar
- Make select one and select boolean work with IE 8 (JavaScript/DOM element creation problem)
Modified:
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=966728&r1=966727&r2=966728&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Thu Jul 22 16:21:11 2010
@@ -40,6 +40,7 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.css.Style;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
+import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
import org.apache.myfaces.tobago.renderkit.html.util.CommandRendererHelper;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
@@ -122,7 +123,10 @@ public abstract class ToolBarRendererBas
FacesContext facesContext, UIToolBar toolBar, UICommandBase command, TobagoResponseWriter writer, Measure width)
throws IOException {
- String onclick = createCommandOnClick(facesContext, command);
+ String suffix = createCommandOnClick(facesContext, command);
+ if (suffix == null) {
+ suffix = "";
+ }
List<SelectItem> items;
@@ -138,10 +142,9 @@ public abstract class ToolBarRendererBas
if (radio != null) {
Object value = radio.getValue();
+ String currentValue = "";
boolean markFirst = !ComponentUtils.hasSelectedValue(items, value);
String radioId = radio.getClientId(facesContext);
- String onClickPrefix = "tobago_toolBarSetRadioValue('" + radioId + "', '";
- String onClickPostfix = onclick != null ? "') ; " + onclick : "";
for (SelectItem item : items) {
final String labelText = item.getLabel();
if (labelText != null) {
@@ -166,18 +169,25 @@ public abstract class ToolBarRendererBas
}
String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
- onclick = onClickPrefix + formattedValue + onClickPostfix;
final boolean checked;
if (item.getValue().equals(value) || markFirst) {
checked = true;
markFirst = false;
- writer.writeJavascript(" " + onClickPrefix + formattedValue + "');");
+ currentValue = formattedValue;
} else {
checked = false;
}
- width = renderToolbarButton(facesContext, toolBar, command, writer, checked, onclick, null, width);
+ String onClick = "tobago_toolBarSetRadioValue('" + radioId + "', '" + formattedValue + "');" + suffix;
+ width = renderToolbarButton(facesContext, toolBar, command, writer, checked, onClick, null, width);
}
+
+ writer.startElement(HtmlConstants.INPUT, null);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
+ writer.writeIdAttribute(radioId);
+ writer.writeNameAttribute(radioId);
+ writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
+ writer.endElement(HtmlConstants.INPUT);
}
return width;
}
@@ -198,14 +208,21 @@ public abstract class ToolBarRendererBas
final String clientId = checkbox.getClientId(facesContext);
String onClick = createCommandOnClick(facesContext, command);
- onClick = "tobago_toolBarCheckToggle('" + clientId + "');" + (onClick != null ? onClick : "");
-
- if (checked) {
- // to initialize the client state
- writer.writeJavascript(" tobago_toolBarCheckToggle('" + clientId + "');\n");
+ if (onClick == null) {
+ onClick = "";
}
+ onClick = "tobago_toolBarCheckToggle('" + clientId + "');" + onClick;
- return renderToolbarButton(facesContext, toolBar, command, writer, checked, onClick, null, width);
+ width = renderToolbarButton(facesContext, toolBar, command, writer, checked, onClick, null, width);
+
+ writer.startElement(HtmlConstants.INPUT, null);
+ writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
+ writer.writeIdAttribute(clientId);
+ writer.writeNameAttribute(clientId);
+ writer.writeAttribute(HtmlAttributes.VALUE, Boolean.toString(checked), false);
+ writer.endElement(HtmlConstants.INPUT);
+
+ return width;
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=966728&r1=966727&r2=966728&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Thu Jul 22 16:21:11 2010
@@ -2435,31 +2435,11 @@ $(document).ready(function() {
function tobago_toolBarCheckToggle(id) {
var element = document.getElementById(id);
- var form = document.forms[0];
- if (element) {
- //LOG.debug("remove " + id);
- form.removeChild(element);
- }
- else {
- //LOG.debug("adding " + id);
- element = document.createElement('INPUT');
- element.type = 'hidden';
- element.name = id;
- element.id = id;
- element.value = 'true';
- form.appendChild(element);
- }
+ element.value = 'true' == element.value ? 'false' : 'true';
}
function tobago_toolBarSetRadioValue(id, value) {
var element = document.getElementById(id);
- if (! element) {
- element = document.createElement('INPUT');
- element.type = 'hidden';
- element.name = id;
- element.id = id;
- document.forms[0].appendChild(element);
- }
element.value = value;
}