ExternalContext exCtx = context.getExternalContext();
Map rqMap = exCtx.getRequestParameterMap();
Object clnId = rqMap.get(component.getClientId(context));
UISimpleTogglePanel panel = (UISimpleTogglePanel) component;
if (clnId != null) {
// enqueue event here for this component or for component with Id
// taken fro forId attribute
String switchType = panel.getSwitchType();
if (!(UISimpleTogglePanel.CLIENT_SWITCH_TYPE.equals(switchType))) {
//xxxx by nick - denis - use constants, please!
if ((panel.isOpened() == UISimpleTogglePanel.EXPANDED)) {
//panel.setOpened(UISimpleTogglePanel.COLLAPSED);
panel.setOpenedSet(UISimpleTogglePanel.COLLAPSED);
} else {
//xxxx by nick - denis - use constants, please!
//panel.setOpened(UISimpleTogglePanel.EXPANDED);
panel.setOpenedSet(UISimpleTogglePanel.EXPANDED);
}
SimpleToggleEvent event = new SimpleToggleEvent(panel, (panel.isOpened()));
if (panel.isImmediate()) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
} else {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
}
event.queue();
} else {
boolean submittedState = Boolean.parseBoolean((String) clnId);
if (panel.isOpened() != submittedState){
//panel.setAjaxSingle(false);
SimpleToggleEvent event = new SimpleToggleEvent(panel, (panel.isOpened()));
if (panel.isImmediate()) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
} else {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
}
event.queue();
}
if (null == panel.getValueBinding("value"))
panel.setOpened(submittedState);
panel.setOpenedSet(submittedState);
}
// in case of "ajax" request and "ajax" switch mode of toggle panel
// set the regions to be rendered (reRendered) after operating this "ajax" request
if (AjaxRendererUtils.isAjaxRequest(context) && panel.getSwitchType().equals(UISimpleTogglePanel.AJAX_SWITCH_TYPE)) {
// add toggle panel itself to rendered list of components
AjaxRendererUtils.addRegionByName(context,
panel,
panel.getId());
// add regions specified in the "reRender" attribute of toggle panel
// to rendered list of components
AjaxRendererUtils.addRegionsFromComponent(panel, context);
}