Skip to content

Commit

Permalink
Prevent ScopedAttributeELResolver to create Session/ViewScope as a si…
Browse files Browse the repository at this point in the history
…de-effect (by calling getValue/setValue)
  • Loading branch information
kalgon committed Aug 20, 2018
1 parent ae66bb9 commit 7a7fb46
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions impl/src/main/java/com/sun/faces/el/ScopedAttributeELResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import com.sun.faces.util.Util;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.application.ApplicationAssociate;

public class ScopedAttributeELResolver extends ELResolver {

Expand Down Expand Up @@ -77,9 +76,12 @@ public Object getValue(ELContext context, Object base, Object property)
}

// check session
result = ec.getSessionMap().get(attribute);
if (result != null) {
return result;
Object session = ec.getSession(false);
if (session != null) {
result = ec.getSessionMap().get(attribute);
if (result != null) {
return result;
}
}

// check application
Expand Down Expand Up @@ -110,7 +112,7 @@ public Class<?> getType(ELContext context, Object base, Object property)
}

@Override
public void setValue(ELContext context, Object base, Object property,
public void setValue(ELContext context, Object base, Object property,
Object val) throws ELException {
if (base != null) {
return;
Expand All @@ -129,9 +131,10 @@ public void setValue(ELContext context, Object base, Object property,
ExternalContext ec = facesContext.getExternalContext();
if ((ec.getRequestMap().get(attribute)) != null) {
ec.getRequestMap().put(attribute, val);
} else if ((facesContext.getViewRoot()) != null && (facesContext.getViewRoot().getViewMap().get(attribute)) != null) {
} else if ((facesContext.getViewRoot()) != null && (facesContext.getViewRoot().getViewMap(false)) != null
&& (facesContext.getViewRoot().getViewMap().get(attribute)) != null) {
facesContext.getViewRoot().getViewMap().put(attribute, val);
} else if ((ec.getSessionMap().get(attribute)) != null) {
} else if ((ec.getSession(false)) != null && (ec.getSessionMap().get(attribute)) != null) {
ec.getSessionMap().put(attribute, val);
} else if ((ec.getApplicationMap().get(attribute)) != null) {
ec.getApplicationMap().put(attribute, val);
Expand Down

0 comments on commit 7a7fb46

Please sign in to comment.