@SuppressWarnings("unchecked")
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
UIModalPanel panel = (UIModalPanel)component;
ExternalContext exCtx = context.getExternalContext();
Map<String, String> rqMap = exCtx.getRequestParameterMap();
Object panelOpenState = rqMap.get(panel.getClientId(context) + "OpenedState");
if (panel.isKeepVisualState()) {
if (null != panelOpenState) {
// Bug https://jira.jboss.org/jira/browse/RF-2466
// Incorrect old:
// panel.setShowWhenRendered(Boolean.parseBoolean((String) clnId));
// ShowWhenRendered can be settled separately with modal panel "showWhenRendered" attribute
// so we should combine ShowWhenRendered || KeepVisualState && (OpenedState==TRUE) against rewriting
boolean showWhenRendered = panel.isShowWhenRendered() || Boolean.parseBoolean((String) panelOpenState);
panel.setShowWhenRendered(showWhenRendered);
Map<String, Object> visualOptions = (Map<String, Object>) panel.getVisualOptions();
Iterator<Entry<String, String>> it = rqMap.entrySet().iterator();
while ( it.hasNext()) {
Map.Entry<String, String> entry = it.next();
int suffixPos = entry.getKey().toString().indexOf(STATE_OPTION_SUFFIX);
if (-1 != suffixPos) {