Author: nbelaevski
Date: 2007-05-22 10:10:22 -0400 (Tue, 22 May 2007)
New Revision: 831
Modified:
trunk/richfaces/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
trunk/richfaces/togglePanel/src/test/java/org/richfaces/renderkit/html/TogglePanelRenderersTest.java
Log:
RF-192 fixed
Modified:
trunk/richfaces/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
---
trunk/richfaces/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2007-05-22
14:08:14 UTC (rev 830)
+++
trunk/richfaces/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2007-05-22
14:10:22 UTC (rev 831)
@@ -80,23 +80,17 @@
public void handleFacets(FacesContext context, UITogglePanel component) throws
IOException {
UITogglePanel panel = (UITogglePanel)component;
List stateOrderList = component.getStateOrderList();
- if (stateOrderList.isEmpty()) {
- throw new FacesException("The \"stateOrder\" attribute of the
togglePanel component shouldn't be empty!");
- }
-
String state = (String) component.getValue();
if (state == null) {
String initialState = component.getInitialState();
if(initialState != null) {
- if (stateOrderList.contains(initialState)){
- state = initialState;
- }
- else{
- state = (String) stateOrderList.get(0);
- }
- }
- else{
- state = (String) stateOrderList.get(0);
+ state = initialState;
+ } else {
+ if (!stateOrderList.isEmpty()) {
+ state = (String) stateOrderList.get(0);
+ } else {
+ throw new FacesException("The \"initialState\" attribute of the
togglePanel component should be set if \"stateOrder\" attribute is
empty!");
+ }
}
}
Modified:
trunk/richfaces/togglePanel/src/test/java/org/richfaces/renderkit/html/TogglePanelRenderersTest.java
===================================================================
---
trunk/richfaces/togglePanel/src/test/java/org/richfaces/renderkit/html/TogglePanelRenderersTest.java 2007-05-22
14:08:14 UTC (rev 830)
+++
trunk/richfaces/togglePanel/src/test/java/org/richfaces/renderkit/html/TogglePanelRenderersTest.java 2007-05-22
14:10:22 UTC (rev 831)
@@ -21,12 +21,14 @@
package org.richfaces.renderkit.html;
-import javax.faces.FacesException;
+import java.io.StringWriter;
+
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.component.html.HtmlForm;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockResponseWriter;
import org.richfaces.component.UIToggleControl;
import org.richfaces.component.UITogglePanel;
@@ -139,12 +141,8 @@
assertEquals(panelRenderer.getComponentClass(), UITogglePanel.class);
+ facesContext.setResponseWriter(new MockResponseWriter(new StringWriter(),
"text/html", "UTF-8"));
togglePanel.setStateOrder(null);
- try {
- panelRenderer.handleFacets(facesContext, togglePanel);
- assertTrue(false);
- } catch (Exception e) {
- assertTrue(e instanceof FacesException);
- }
+ panelRenderer.handleFacets(facesContext, togglePanel);
}
}
Show replies by date