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 2013/04/26 16:57:19 UTC
svn commit: r1476240 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/...
Author: lofwyr
Date: Fri Apr 26 14:57:09 2013
New Revision: 1476240
URL: http://svn.apache.org/r1476240
Log:
TOBAGO-1258 New attribute "omit" for commands
Added:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsOmit.java
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandBase.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/AbstractCommandTagDeclaration.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java
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/java/org/apache/myfaces/tobago/renderkit/html/Command.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java Fri Apr 26 14:57:09 2013
@@ -126,6 +126,7 @@ public final class Attributes {
public static final String NAME = "name";
public static final String NAVIGATE = "navigate";
public static final String NUMBER_STYLE = "numberStyle";
+ public static final String OMIT = "omit";
public static final String ONCHANGE = "onchange";
public static final String ONCLICK = "onclick";
public static final String ORDER_BY = "orderBy";
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandBase.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandBase.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandBase.java Fri Apr 26 14:57:09 2013
@@ -93,4 +93,6 @@ public abstract class AbstractUICommandB
public abstract boolean isTransition();
public abstract String[] getRenderedPartially();
+
+ public abstract boolean isOmit();
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDatePicker.java Fri Apr 26 14:57:09 2013
@@ -73,4 +73,8 @@ public abstract class AbstractUIDatePick
public boolean isTransition() {
return true;
}
+
+ public boolean isOmit() {
+ return false;
+ }
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/AbstractCommandTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/AbstractCommandTagDeclaration.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/AbstractCommandTagDeclaration.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/AbstractCommandTagDeclaration.java Fri Apr 26 14:57:09 2013
@@ -20,5 +20,5 @@
package org.apache.myfaces.tobago.internal.taglib.declaration;
public interface AbstractCommandTagDeclaration extends HasAction, HasActionListener, IsImmediateCommand,
- HasOnclick, HasLink, HasResource, IsTransition, HasTarget, HasRenderedPartially, IsDisabled {
+ HasOnclick, HasLink, HasResource, IsTransition, HasTarget, HasRenderedPartially, IsDisabled, IsOmit {
}
Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsOmit.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsOmit.java?rev=1476240&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsOmit.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/IsOmit.java Fri Apr 26 14:57:09 2013
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.internal.taglib.declaration;
+
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+
+public interface IsOmit {
+ /**
+ * Flag indicating that the action of this element, will not be executed from client side
+ * (e. g. when the user clicks a button.
+ * When setting this value to true, the action will not be executed by the Tobago, but it can executed
+ * by JavaScript.
+ * This attribute is useful, when you want to add JavaScript event handlers to commands manually.
+ * In this case you usually don't want a submit with a full reload of the page.
+ */
+ @TagAttribute()
+ @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+ void setOmit(String omit);
+}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.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/MenuCommandRenderer.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java Fri Apr 26 14:57:09 2013
@@ -102,7 +102,8 @@ public class MenuCommandRenderer extends
LOG.warn("Menu item has label=null where clientId=" + clientId);
}
final String formattedValue = RenderUtils.getFormattedValue(facesContext, radio, item.getValue());
- final CommandMap map = new CommandMap(new Command(clientId, null, null, null, null, null, null, null, null));
+ final CommandMap map = new CommandMap(
+ new Command(clientId, null, null, null, null, null, null, null, null, null));
encodeItem(facesContext, writer, null, label, map, disabled, firstLevel, image, formattedValue, "selectOne");
}
encodeHidden(writer, hiddenId, getCurrentValue(facesContext, radio));
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.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/SheetRenderer.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Fri Apr 26 14:57:09 2013
@@ -783,7 +783,7 @@ public class SheetRenderer extends Layou
}
final CommandMap map = new CommandMap();
final Command click = new Command(sortCommand.getClientId(facesContext),
- null, null, null, new String[]{sheet.getClientId(facesContext)}, null, null, null, null);
+ null, null, null, new String[]{sheet.getClientId(facesContext)}, null, null, null, null, null);
map.setClick(click);
writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.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/ToolBarRenderer.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRenderer.java Fri Apr 26 14:57:09 2013
@@ -49,7 +49,7 @@ public class ToolBarRenderer extends Too
HtmlRendererUtils.renderDojoDndItem(toolBar, writer, true);
writer.writeClassAttribute(Classes.create(toolBar));
Style style = new Style(facesContext, toolBar);
- boolean right = toolBar instanceof UIToolBar && UIToolBar.ORIENTATION_RIGHT.equals(toolBar.getOrientation());
+ boolean right = UIToolBar.ORIENTATION_RIGHT.equals(toolBar.getOrientation());
if (right) {
style.setTextAlign(TextAlign.RIGHT);
}
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=1476240&r1=1476239&r2=1476240&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 Fri Apr 26 14:57:09 2013
@@ -395,6 +395,7 @@ public abstract class ToolBarRendererBas
if (map != null) {
writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
}
+ HtmlRendererUtils.writeDataAttributes(facesContext, writer, command);
if (value != null) {
writer.writeAttribute(DataAttributes.VALUE, value, true);
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Command.java Fri Apr 26 14:57:09 2013
@@ -53,6 +53,7 @@ public class Command {
private String confirmation;
private Integer delay;
private Popup popup;
+ private Boolean omit;
/**
* @deprecated Script will not work when CSP is activated
*/
@@ -64,7 +65,7 @@ public class Command {
public Command(
String action, Boolean transition, String target, String url, String[] partially, String focus,
- String confirmation, Integer delay, Popup popup) {
+ String confirmation, Integer delay, Popup popup, Boolean omit) {
this.action = action;
this.transition = transition;
this.target = target;
@@ -74,9 +75,10 @@ public class Command {
this.confirmation = confirmation;
this.delay = delay;
this.popup = popup;
+ this.omit = omit;
}
- public Command(FacesContext facesContext, AbstractUICommandBase command) {
+ public Command(FacesContext facesContext, AbstractUICommandBase command) {
this(
null,
command.isTransition(),
@@ -86,7 +88,8 @@ public class Command {
null,
getConfirmation(command),
null,
- Popup.createPopup(command));
+ Popup.createPopup(command),
+ command.isOmit());
if (command.getOnclick() != null) {
script = command.getOnclick();
}
@@ -128,6 +131,10 @@ public class Command {
if (delay > 0) {
this.delay = delay;
}
+ // omit == false is the default
+ if (!ComponentUtils.getBooleanAttribute(facetComponent, Attributes.OMIT)) {
+ this.omit = Boolean.TRUE;
+ }
}
private static String getConfirmation(AbstractUICommandBase command) {
@@ -207,6 +214,14 @@ public class Command {
this.popup = popup;
}
+ public Boolean getOmit() {
+ return omit;
+ }
+
+ public void setOmit(Boolean omit) {
+ this.omit = omit;
+ }
+
/**
* @deprecated Script will not work when CSP is activated
*/
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java Fri Apr 26 14:57:09 2013
@@ -138,6 +138,10 @@ public class JsonUtils {
if (script != null) {
encode(builder, "script", script);
}
+ Boolean omit = command.getOmit();
+ if (omit != null && omit) { // false is the default, so encoding is needed.
+ encode(builder, "omit", omit);
+ }
if (builder.length() - initialLength > 0) {
assert builder.charAt(builder.length() - 1) == ',';
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=1476240&r1=1476239&r2=1476240&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 Fri Apr 26 14:57:09 2013
@@ -1009,31 +1009,33 @@ var Tobago = {
if (commands.click) {
command.click(function() {
- if (commands.click.confirmation == null || confirm(commands.click.confirmation)) {
- var popup = commands.click.popup;
- if (popup && popup.command == "close" && popup.immediate) {
- Tobago.Popup.close(this);
- } else {
- if (popup && popup.command == "close") {
- Tobago.Popup.unlockBehind();
- }
- var action = commands.click.action ? commands.click.action : jQuery(this).attr("id");
- if (commands.click.partially) {
- if (popup && popup.command == "open") {
- Tobago.Popup.openWithAction(this, commands.click.partially, action);
+ if (commands.click.omit != true) {
+ if (commands.click.confirmation == null || confirm(commands.click.confirmation)) {
+ var popup = commands.click.popup;
+ if (popup && popup.command == "close" && popup.immediate) {
+ Tobago.Popup.close(this);
+ } else {
+ if (popup && popup.command == "close") {
+ Tobago.Popup.unlockBehind();
+ }
+ var action = commands.click.action ? commands.click.action : jQuery(this).attr("id");
+ if (commands.click.partially) {
+ if (popup && popup.command == "open") {
+ Tobago.Popup.openWithAction(this, commands.click.partially, action);
+ } else {
+ Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
+ }
+ } else if (commands.click.url) {
+ Tobago.navigateToUrl(commands.click.url);
+ } else if (commands.click.script) { // XXX this case is deprecated.
+ // not allowed with Content Security Policy (CSP)
+ eval(commands.click.script);
} else {
- Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
+ Tobago.submitAction(this, action, commands.click);
+ }
+ if (popup && popup.command == "close") {
+ Tobago.Popup.close();
}
- } else if (commands.click.url) {
- Tobago.navigateToUrl(commands.click.url);
- } else if (commands.click.script) { // XXX this case is deprecated.
- // not allowed with Content Security Policy (CSP)
- eval(commands.click.script);
- } else {
- Tobago.submitAction(this, action, commands.click);
- }
- if (popup && popup.command == "close") {
- Tobago.Popup.close();
}
}
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java?rev=1476240&r1=1476239&r2=1476240&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java Fri Apr 26 14:57:09 2013
@@ -34,54 +34,54 @@ public class JsonUtilsUnitTest extends A
@Test
public void empty() {
- CommandMap commandMap = new CommandMap();
- Assert.assertEquals("{}", JsonUtils.encode(commandMap));
+ CommandMap map = new CommandMap();
+ Assert.assertEquals("{}", JsonUtils.encode(map));
}
@Test
public void click() {
- CommandMap commandMap = new CommandMap();
- commandMap.setClick(new Command(null, null, null, null, new String[0], null, null, null, null));
+ CommandMap map = new CommandMap();
+ map.setClick(new Command(null, null, null, null, new String[0], null, null, null, null, null));
final String expected = "{'click':{}}".replaceAll("'", "\"");
- Assert.assertEquals(expected, JsonUtils.encode(commandMap));
+ Assert.assertEquals(expected, JsonUtils.encode(map));
}
@Test
public void change() {
- CommandMap commandMap = new CommandMap();
- commandMap.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null));
+ CommandMap map = new CommandMap();
+ map.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null, null));
final String expected = "{'change':{}}".replaceAll("'", "\"");
- Assert.assertEquals(expected, JsonUtils.encode(commandMap));
+ Assert.assertEquals(expected, JsonUtils.encode(map));
}
@Test
public void two() {
- CommandMap commandMap = new CommandMap();
- commandMap.addCommand("click", new Command(null, null, "target", null, new String[0], null, null, null, null));
- commandMap.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null));
+ CommandMap map = new CommandMap();
+ map.addCommand("click", new Command(null, null, "target", null, new String[0], null, null, null, null, null));
+ map.addCommand("change", new Command(null, null, null, null, new String[0], null, null, null, null, null));
final String expected = "{'click':{'target':'target'},'change':{}}".replaceAll("'", "\"");
- Assert.assertEquals(expected, JsonUtils.encode(commandMap));
+ Assert.assertEquals(expected, JsonUtils.encode(map));
}
@Test
public void transition() {
CommandMap commandMap = new CommandMap();
- commandMap.setClick(new Command(null, false, null, null, new String[0], null, null, null, null));
+ commandMap.setClick(new Command(null, false, null, null, new String[0], null, null, null, null, null));
final String expected = "{'click':{'transition':false}}".replaceAll("'", "\"");
Assert.assertEquals(expected, JsonUtils.encode(commandMap));
}
@Test
public void more() {
- CommandMap commandMap = new CommandMap();
+ CommandMap map = new CommandMap();
final AbstractUICommandBase command = (AbstractUICommandBase)
CreateComponentUtils.createComponent(facesContext, ComponentTypes.BUTTON, RendererTypes.BUTTON, "command");
command.getAttributes().put(Attributes.POPUP_CLOSE, "immediate");
command.setRenderedPartially(new String[] {"popup"});
- commandMap.setClick(new Command(
+ map.setClick(new Command(
"ns:actionId", false, "_blank", "http://www.apache.org/", new String[]{"id1", "id2"}, "id_focus",
- "Really?", 1000, Popup.createPopup(command)));
+ "Really?", 1000, Popup.createPopup(command), true));
final String expected = (
"{"
+ "'click':{"
@@ -96,10 +96,11 @@ public class JsonUtilsUnitTest extends A
+ "'popup':{"
+ "'command':'close',"
+ "'immediate':true"
- + "}"
+ + "},"
+ + "'omit':true"
+ "}"
+ "}").replaceAll("'", "\"");
- Assert.assertEquals(expected, JsonUtils.encode(commandMap));
+ Assert.assertEquals(expected, JsonUtils.encode(map));
}
}