I have a TabView containing a Picklist:
My xtml page:
Code: Select all
<h:form>
<p:tabView var="auditorium" value="#{auditoriumController.auditoriums}">
<p:ajax event="tabChange" listener="#{auditoriumController.onTabChange}"/>
<p:tab title="#{auditorium.number}">
<p:fieldset id="auditoriumInfoFieldset" legend="Auditorium Info" toggleable="true" style="width: 45%; float: left">
<p:panelGrid>
...
</p:panelGrid>
</p:fieldset>
<p:fieldset id="associatedDevicesFieldset" legend="Associated devices" toggleable="true" style="width: 45%;">
<p:pickList value="#{auditoriumController.devices}" var="device" itemValue="#{device}" itemLabel="#{device.manufacturer}" converter="deviceConverter">
<f:facet name="sourceCaption">Available</f:facet>
<f:facet name="targetCaption">Associated</f:facet>
<p:ajax event="transfer" listener="#{auditoriumController.onDeviceTransfer}" />
</p:pickList>
</p:fieldset>
</p:tab>
</p:tabView>
</h:form>
Code: Select all
@ManagedBean(name = "auditoriumController")
@ViewScoped
public class AuditoriumController implements Serializable {
@PostConstruct
public void postConstruct() {
devices = new DualListModel<>();
auditoriums = auditoriumFacade.findAll();
if (auditoriums != null && !auditoriums.isEmpty()) {
setSelectedAuditorium(auditoriums.get(0));
populateDeviceList();
}
}
public void onTabChange(TabChangeEvent event) {
setSelectedAuditorium((Auditorium) event.getData());
System.out.println("onTabChange : " + selectedAuditorium);
populateDeviceList();
}
private void populateDeviceList() {
// Filling the dual list
}
public void onDeviceTransfer(TransferEvent event) {
for(Object item : event.getItems()) {
Device device = deviceFacade.find(((Device) item).getId());
// Doing my stuff with the items
}
}
}
}
Code: Select all
@FacesConverter(forClass=Device.class, value="deviceConverter")
public class DeviceConverter implements Converter {
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
Device device = new Device();
device.setId(Long.valueOf(string));
return device;
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object o) {
return String.valueOf(((Device) o).getId());
}
}
If I remove the picklist in my xtml page it works fine...
Any idea about what could cause this issue? Am I doing something wrong?
Thanks for your precious help !
Mehdi