Author: Alex.Kolonitsky
Date: 2011-01-10 09:34:39 -0500 (Mon, 10 Jan 2011)
New Revision: 20932
Modified:
trunk/examples/output-demo/src/main/webapp/examples/togglePanel-mixed.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
Log:
RF-9894: Toggle panel item: no item displayed when rendered is false
Modified: trunk/examples/output-demo/src/main/webapp/examples/togglePanel-mixed.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/togglePanel-mixed.xhtml 2011-01-10
14:19:14 UTC (rev 20931)
+++ trunk/examples/output-demo/src/main/webapp/examples/togglePanel-mixed.xhtml 2011-01-10
14:34:39 UTC (rev 20932)
@@ -15,9 +15,10 @@
<ui:define name="body">
<h:form id="f">
<pn:togglePanel id="panel" activeItem="name1"
switchType="client" lang="en" cycledSwitching="true" >
- <pn:togglePanelItem name="name1" >hello name1
client</pn:togglePanelItem>
+ <pn:togglePanelItem name="name1" rendered="false"
>hello name1 client</pn:togglePanelItem>
<pn:togglePanelItem name="name2"
onenter="alert('onenter ajax');" switchType="ajax">hello
name2 ajax</pn:togglePanelItem>
<pn:togglePanelItem name="name3"
switchType="server">hello name3 server</pn:togglePanelItem>
+ <pn:togglePanelItem name="name4" >hello
name4</pn:togglePanelItem>
</pn:togglePanel>
<h:outputLink>
@@ -34,6 +35,11 @@
<ou:toggleControl targetPanel="panel"
targetItem="name3" event="click" />
name3 server
</h:outputLink>
+ |
+ <h:outputLink>
+ <ou:toggleControl targetPanel="panel"
targetItem="name4" event="click" />
+ name4 client disabled
+ </h:outputLink>
<br />
<h:outputLink>
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2011-01-10
14:19:14 UTC (rev 20931)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2011-01-10
14:34:39 UTC (rev 20932)
@@ -22,6 +22,7 @@
package org.richfaces.component;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -138,6 +139,20 @@
// ----------------------------------------------------- UIComponent Methods
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException {
+ AbstractTogglePanelItem item = this.getItem(getActiveItem());
+ if (item == null || !item.isRendered()) {
+ List<AbstractTogglePanelItem> renderedItems = this.getRenderedItems();
+ if (!renderedItems.isEmpty()) {
+ setActiveItem(renderedItems.get(0).getName());
+ }
+ }
+
+ super.encodeBegin(context);
+ }
+
/**
* <p>Specialized decode behavior on top of that provided by the
* superclass. In addition to the standard
@@ -212,6 +227,7 @@
Application app = context.getApplication();
app.publishEvent(context, PreValidateEvent.class, this);
+
// Process all the facets and children of this component
Iterator<UIComponent> kids = getFacetsAndChildren();
String activeItem = getActiveItemValue();
@@ -456,20 +472,24 @@
public AbstractTogglePanelItem getItemByIndex(final int index) {
List<AbstractTogglePanelItem> children = getRenderedItems();
- if (isCycledSwitching()) {
+ if (index < 0 || index >= children.size()) {
+ return null;
+ } else if (isCycledSwitching()) {
int size = getRenderedItems().size();
return children.get((size + index) % size);
- } else if (index < 0 || index >= children.size()) {
- return null;
} else {
return children.get(index);
}
}
public List<AbstractTogglePanelItem> getRenderedItems() {
+ return getItems(false);
+ }
+
+ public List<AbstractTogglePanelItem> getItems(boolean isRendered) {
List<AbstractTogglePanelItem> res = new
ArrayList<AbstractTogglePanelItem>(getChildCount());
for (UIComponent child : getChildren()) {
- if (child.isRendered() && child instanceof AbstractTogglePanelItem)
{
+ if ((isRendered || child.isRendered()) && child instanceof
AbstractTogglePanelItem) {
res.add((AbstractTogglePanelItem) child);
}
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2011-01-10
14:19:14 UTC (rev 20931)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2011-01-10
14:34:39 UTC (rev 20932)
@@ -46,7 +46,6 @@
/**
* @author akolonitsky
- * @since -4712-01-01
*/
@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
Show replies by date