Problem with dynamic simpleTogglePanels inside a tabPanel
taroman Jul 23, 2007 1:26 PMI?m having a problem with dynamically generated rich:simpleTogglePanels within a rich:dataGrid (or rich:dataTable) that are wrapped within a rich:tabPanel. I can click the simpleTogglePanels and it opens as expected. If I change tabs and go back to the tab containing the simpleTogglePanels, all of the simpleTogglePanels within the dataGrid/dataTable are opened. If I close one of the simpleTogglePanels and switch tabs again and go back, all of the simpleTogglePanels are closed.
It only seems to occur with simpleTogglePanels within the dataGrid/dataTable because as you can see from my example code, the simpleTogglePanels outside the dataGrid/dataTable behave as expected when switching tabs.
Any ideas? I?m fairly new to JSF/Richfaces so let me know if I?ve made incorrect assumptions?
Thanks!
FYI: Using Jboss 4.2.0GA/Seam 2.0.0.BETA1/Richfaces 3.0.1/Ajax4jsf 1.1.1
Note: the local interface ?ListChannels? is omitted to save a little space?
---------------------
Markup for Main page with tabPanel:
<ui:composition (namespaces removed)>
<ui:define name=?body?>
<rich:tabPanel switchType=?ajax?>
<rich:tab label=?Home?>
<rich:panel>
<f:facet name=?header?>Home</f:facet>
<p>Put interesting Home stuff here</p>
</rich:panel>
</rich:tab>
<rich:tab label=?Control?>
<div class=?control?>
<ui:include src=?controlNew.xhtml?/>
</div>
</rich:tab>
<rich:tab label=?Queries?>
<rich:panel>
<f:facet name=?header?>DB Query</f:facet>
<p>Put DB Query components here</p>
</rich:panel>
</rich:tab>
</rich:tabPanel>
</ui:define>
</ui:composition>
---------------------
Markup for ?Control? tab containing togglePanels (controlNew.xhtml):
<rich:panel (namespaces removed)>
<f:facet name=?header?>Control Grid</f:facet>
<h:outputText value=?No Channels Configured?
rendered=?#{channels.rowCount==0}?/>
<rich:dataGrid id=?chanGrid? var=?channel? value=?#{channels}?
rendered=?#{channels.rowCount>0}? border=?0?
cellspacing=?5? columns=?1?>
<rich:simpleTogglePanel opened=?false? switchType=?ajax?
label=?#{channel.channelId} #{channel.name}?>
<h:outputText value=?Put control components here??/>
</rich:simpleTogglePanel>
</rich:dataGrid>
<!? These simpleTogglePanels behave as expected when traversing
the tabPanel tabs? à
<rich:simpleTogglePanel opened=?false? switchType=?ajax? label=?Test One?>
<h:outputText value=?Put something in here?/>
</rich:simpleTogglePanel>
<rich:simpleTogglePanel opened=?false? switchType=?ajax? label=?Test Two?>
<h:outputText value=?Put something in here?/>
</rich:simpleTogglePanel>
<rich:simpleTogglePanel opened=?false? switchType=?ajax? label=?Test Two?>
<h:outputText value=?Put something in here?/>
</rich:simpleTogglePanel>
</rich:panel>
---------------------
Here is the backing bean (ListChannelAction):
package components;
import static org.jboss.seam.ScopeType.SESSION;
import java.io.Serializable;
import java.util.*;
import javax.ejb.*;
import javax.persistence.*;
import org.jboss.seam.annotations.*;
import org.jboss.seam.annotations.datamodel.*;
import org.jboss.seam.log.Log;
import pojos.Channel;
@Stateful
@Scope(SESSION)
@Name(?channelList?)
public class ListChannelAction implements ListChannels, Serializable {
private static final long serialVersionUID = 1L;
@Logger
private Log log;
@DataModel
private List<Channel> channels;
@DataModelSelection(?channels?);
@Out(required=false)
private Channel channel;
@Factory(?channels?)
public void getChannels() {
// Hard-coded channel create for now
int numchannels=3;
channels = new ArrayList<Channel>();
for (int I=0; I < numChannels; I++) {
channels.add(new Channel(I, ?Channel ?+I));
}
}
@Destroy @Remove
public void destroy() {}
}
---------------------
And the POJO representing ?Channel?:
package pojos;
import java.io.Serializable;
public class Channel implements Serializable {
private static final long serialVersionUID = 1L;
private int channelId;
private String name;
public Channel() {}
public Channel(int channelId, String name) {
this.channelId = channelId;
this.name = name;
}
// (Sets and Gets removed for space)
}