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 2016/11/16 12:28:55 UTC
svn commit: r1769966 - in /myfaces/tobago/trunk/tobago-core/src:
main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/
main/java/org/apache/myfaces/tobago/util/
test/java/org/apache/myfaces/tobago/internal/util/
test/java/org/apache/myfaces/...
Author: lofwyr
Date: Wed Nov 16 12:28:55 2016
New Revision: 1769966
URL: http://svn.apache.org/viewvc?rev=1769966&view=rev
Log:
cleanup
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/CreateComponentUtils.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/ClassesUnitTest.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/ComponentUtilsUnitTest.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Wed Nov 16 12:28:55 2016
@@ -69,7 +69,6 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.internal.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.CreateComponentUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -155,12 +154,12 @@ public class SheetRenderer extends Rende
UIComponent header = sheet.getHeader();
if (header == null) {
- header = CreateComponentUtils.createComponent(facesContext, UIPanel.COMPONENT_TYPE, null, "_header");
+ header = ComponentUtils.createComponent(facesContext, UIPanel.COMPONENT_TYPE, null, "_header");
final List<AbstractUIColumnBase> columns = sheet.getAllColumns();
int i = 0;
for (final AbstractUIColumnBase column : columns) {
if (!(column instanceof AbstractUIRow)) {
- final AbstractUIOut out = (AbstractUIOut) CreateComponentUtils.createComponent(
+ final AbstractUIOut out = (AbstractUIOut) ComponentUtils.createComponent(
facesContext, UIOut.COMPONENT_TYPE, RendererTypes.Out, "_col" + i);
// out.setValue(column.getLabel());
ValueExpression valueExpression = column.getValueExpression(Attributes.label.getName());
@@ -807,7 +806,7 @@ public class SheetRenderer extends Rende
if (sortCommand == null) {
final String columnId = column.getClientId(facesContext);
final String sorterId = columnId.substring(columnId.lastIndexOf(":") + 1) + "_" + UISheet.SORTER_ID;
- sortCommand = (UILink) CreateComponentUtils.createComponent(
+ sortCommand = (UILink) ComponentUtils.createComponent(
facesContext, UILink.COMPONENT_TYPE, RendererTypes.Link, sorterId);
final AjaxBehavior reloadBehavior = createReloadBehavior(sheet);
sortCommand.addClientBehavior("click", reloadBehavior);
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Wed Nov 16 12:28:55 2016
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.util;
import org.apache.commons.collections.CollectionUtils;
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.context.TransientStateHolder;
import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
@@ -845,4 +846,14 @@ public final class ComponentUtils {
}
}
+ public static UIComponent createComponent(
+ final FacesContext facesContext, final String componentType, final RendererTypes rendererType,
+ final String clientId) {
+ final UIComponent component = facesContext.getApplication().createComponent(componentType);
+ if (rendererType != null) {
+ component.setRendererType(rendererType.name());
+ }
+ component.setId(clientId);
+ return component;
+ }
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/CreateComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/CreateComponentUtils.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/CreateComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/CreateComponentUtils.java Wed Nov 16 12:28:55 2016
@@ -19,74 +19,9 @@
package org.apache.myfaces.tobago.util;
-import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.component.UIMenuSelectOne;
-import org.apache.myfaces.tobago.component.UISelectBooleanCheckbox;
-import org.apache.myfaces.tobago.internal.component.AbstractUISelectBooleanCheckbox;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
public final class CreateComponentUtils {
private CreateComponentUtils() {
}
- public static UIComponent createComponent(
- final String componentType, final RendererTypes rendererType, final String clientId) {
- final FacesContext facesContext = FacesContext.getCurrentInstance();
- return createComponent(facesContext, componentType, rendererType, clientId);
- }
-
- public static UIComponent createComponent(
- final FacesContext facesContext, final String componentType, final RendererTypes rendererType,
- final String clientId) {
- final UIComponent component = facesContext.getApplication().createComponent(componentType);
- if (rendererType != null) {
- component.setRendererType(rendererType.name());
- }
- component.setId(clientId);
- return component;
- }
-
- public static UIMenuSelectOne createUIMenuSelectOneFacet(
- final FacesContext facesContext, final UICommand command, final String clientId) {
-
- final UIMenuSelectOne radio = (UIMenuSelectOne) createComponent(
- facesContext, UIMenuSelectOne.COMPONENT_TYPE, RendererTypes.SelectOneRadio, clientId);
- //noinspection unchecked
- ComponentUtils.setFacet(command, Facets.radio, radio);
- final ValueBinding valueBinding = command.getValueBinding(Attributes.value.getName());
- if (valueBinding != null) {
- radio.setValueBinding(Attributes.value.getName(), valueBinding);
- } else {
- radio.setValue(command.getValue());
- }
- return radio;
- }
-
- public static AbstractUISelectBooleanCheckbox createUISelectBooleanFacetWithId(
- final FacesContext facesContext, final UICommand command) {
- return createUISelectBooleanFacet(facesContext, command, facesContext.getViewRoot().createUniqueId());
- }
-
- public static AbstractUISelectBooleanCheckbox createUISelectBooleanFacet(
- final FacesContext facesContext, final UICommand command, final String clientId) {
- final AbstractUISelectBooleanCheckbox checkbox = (AbstractUISelectBooleanCheckbox) createComponent(
- facesContext, UISelectBooleanCheckbox.COMPONENT_TYPE, RendererTypes.SelectBooleanCheckbox, clientId);
- //noinspection unchecked
- ComponentUtils.setFacet(command, Facets.checkbox, checkbox);
- final ValueBinding valueBinding = command.getValueBinding(Attributes.value.getName());
- if (valueBinding != null) {
- checkbox.setValueBinding(Attributes.value.getName(), valueBinding);
- } else {
- //noinspection unchecked
- checkbox.setValue(command.getValue());
- }
- return checkbox;
- }
}
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java Wed Nov 16 12:28:55 2016
@@ -30,7 +30,6 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.internal.renderkit.Command;
import org.apache.myfaces.tobago.internal.renderkit.CommandMap;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.CreateComponentUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -84,7 +83,7 @@ public class JsonUtilsUnitTest extends A
public void more() {
final CommandMap map = new CommandMap();
final AbstractUICommand command = (AbstractUICommand)
- CreateComponentUtils.createComponent(facesContext, UIButton.COMPONENT_TYPE, RendererTypes.Button, "command");
+ ComponentUtils.createComponent(facesContext, UIButton.COMPONENT_TYPE, RendererTypes.Button, "command");
ComponentUtils.setAttribute(command, Attributes.popupClose, "immediate");
map.setClick(new Command(
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/ClassesUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/ClassesUnitTest.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/ClassesUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/ClassesUnitTest.java Wed Nov 16 12:28:55 2016
@@ -25,7 +25,6 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.context.Markup;
import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
import org.apache.myfaces.tobago.util.ComponentUtils;
-import org.apache.myfaces.tobago.util.CreateComponentUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -35,21 +34,21 @@ public class ClassesUnitTest extends Abs
@Test
public void testSimple() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
Assert.assertEquals("tobago-in-simple", Classes.create(in, "simple").getName());
}
@Test
public void testFull() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
Assert.assertEquals("tobago-in", Classes.create(in).getName());
}
@Test
public void testDisabled() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setDisabled(true);
updateMarkup(in);
@@ -58,7 +57,7 @@ public class ClassesUnitTest extends Abs
@Test
public void testReadonly() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setReadonly(true);
updateMarkup(in);
@@ -67,7 +66,7 @@ public class ClassesUnitTest extends Abs
@Test
public void testDisabledReadonly() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setDisabled(true);
in.setReadonly(true);
@@ -78,7 +77,7 @@ public class ClassesUnitTest extends Abs
@Test
public void testError() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setValid(false);
updateMarkup(in);
@@ -87,7 +86,7 @@ public class ClassesUnitTest extends Abs
@Test
public void testMarkup() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setMarkup(Markup.valueOf("important"));
updateMarkup(in);
@@ -96,14 +95,14 @@ public class ClassesUnitTest extends Abs
@Test
public void testSub() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
Assert.assertEquals("tobago-in-sub", Classes.create(in, "sub").getName());
}
@Test
public void testMixed() {
- final UIIn in = (UIIn) CreateComponentUtils.createComponent(
+ final UIIn in = (UIIn) ComponentUtils.createComponent(
getFacesContext(), UIIn.COMPONENT_TYPE, RendererTypes.In, "in");
in.setDisabled(true);
in.setReadonly(true);
Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/ComponentUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/ComponentUtilsUnitTest.java?rev=1769966&r1=1769965&r2=1769966&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/ComponentUtilsUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/ComponentUtilsUnitTest.java Wed Nov 16 12:28:55 2016
@@ -27,6 +27,7 @@ import org.junit.Assert;
import org.junit.Test;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
public class ComponentUtilsUnitTest extends AbstractTobagoTestBase {
@@ -41,8 +42,11 @@ public class ComponentUtilsUnitTest exte
@Test
public void testFindDescendant() {
- final UIComponent p = CreateComponentUtils.createComponent(UIPanel.COMPONENT_TYPE, RendererTypes.Panel, "p");
- final UIComponent i = CreateComponentUtils.createComponent(UIIn.COMPONENT_TYPE, RendererTypes.In, "i");
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+ final UIComponent p = ComponentUtils.createComponent(
+ facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.Panel, "p");
+ final UIComponent i = ComponentUtils.createComponent(
+ facesContext, UIIn.COMPONENT_TYPE, RendererTypes.In, "i");
p.getChildren().add(i);
final UIIn in = ComponentUtils.findDescendant(p, UIIn.class);