clanup of optimizaton code
fixed bug in external context for jsf practical doc improvements
This commit is contained in:
@@ -1826,7 +1826,7 @@ public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2>
|
||||
<title>JSF Plumbing (faces-config.xml)</title>
|
||||
<title>JSF Setup in faces-config.xml</title>
|
||||
<para>
|
||||
The Spring framework has several classes to help JSF applications
|
||||
to use Spring beans as JSF managed beans and to do dependency injection
|
||||
@@ -1904,6 +1904,8 @@ public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
The JSF version of the sellitem flow definition is simpler because JSF components
|
||||
care for data binding and validation.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
In its web flow definition Sellitem-JSF uses actual
|
||||
JSP names (instead of the logical view names used
|
||||
|
||||
@@ -54,11 +54,34 @@ public class PortletExternalContext implements ExternalContext {
|
||||
*/
|
||||
private PortletResponse response;
|
||||
|
||||
/**
|
||||
* An accessor for the portlet request parameter map.
|
||||
*/
|
||||
private ParameterMap requestParameterMap;
|
||||
|
||||
/**
|
||||
* An accessor for the portlet request attribute map.
|
||||
*/
|
||||
private MutableAttributeMap requestMap;
|
||||
|
||||
/**
|
||||
* An accessor for the local portlet session map.
|
||||
*/
|
||||
private SharedAttributeMap sessionMap;
|
||||
|
||||
/**
|
||||
* An accessor for the global portlet session map.
|
||||
*/
|
||||
private SharedAttributeMap globalSessionMap;
|
||||
|
||||
/**
|
||||
* An accessor for the portlet context application map.
|
||||
*/
|
||||
private SharedAttributeMap applicationMap;
|
||||
|
||||
/**
|
||||
* An accessor for the portlet user info map.
|
||||
*/
|
||||
private MutableAttributeMap userInfoMap;
|
||||
|
||||
/**
|
||||
@@ -71,7 +94,6 @@ public class PortletExternalContext implements ExternalContext {
|
||||
this.context = context;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
|
||||
this.requestParameterMap = new LocalParameterMap(new PortletRequestParameterMap(request));
|
||||
this.requestMap = new LocalAttributeMap(new PortletRequestMap(request));
|
||||
this.sessionMap = new LocalSharedAttributeMap(new PortletSessionMap(request, PortletSession.PORTLET_SCOPE));
|
||||
@@ -86,10 +108,12 @@ public class PortletExternalContext implements ExternalContext {
|
||||
}
|
||||
|
||||
public String getDispatcherPath() {
|
||||
// returns null in a portlet environment
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRequestPathInfo() {
|
||||
// returns null in a portlet environment
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ import org.springframework.webflow.core.collection.ParameterMap;
|
||||
import org.springframework.webflow.core.collection.SharedAttributeMap;
|
||||
|
||||
/**
|
||||
* Provides contextual information about an HTTP Servlet environment that has
|
||||
* interacted with Spring Web Flow.
|
||||
* Provides contextual information about an HTTP Servlet environment that has interacted with Spring Web Flow.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Erwin Vervaet
|
||||
@@ -51,15 +50,29 @@ public class ServletExternalContext implements ExternalContext {
|
||||
* The response.
|
||||
*/
|
||||
private HttpServletResponse response;
|
||||
|
||||
|
||||
/**
|
||||
* An accessor for the HTTP request parameter map.
|
||||
*/
|
||||
private ParameterMap requestParameterMap;
|
||||
|
||||
/**
|
||||
* An accessor for the HTTP request attribute map.
|
||||
*/
|
||||
private MutableAttributeMap requestMap;
|
||||
|
||||
/**
|
||||
* An accessor for the HTTP session map.
|
||||
*/
|
||||
private SharedAttributeMap sessionMap;
|
||||
|
||||
/**
|
||||
* An accessor for the servlet context application map.
|
||||
*/
|
||||
private SharedAttributeMap applicationMap;
|
||||
|
||||
/**
|
||||
* Create a new external context wrapping given servlet HTTP request and
|
||||
* response and given servlet context.
|
||||
* Create a new external context wrapping given servlet HTTP request and response and given servlet context.
|
||||
* @param context the servlet context
|
||||
* @param request the HTTP request
|
||||
* @param response the HTTP response
|
||||
@@ -68,7 +81,6 @@ public class ServletExternalContext implements ExternalContext {
|
||||
this.context = context;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
|
||||
this.requestParameterMap = new LocalParameterMap(new HttpServletRequestParameterMap(request));
|
||||
this.requestMap = new LocalAttributeMap(new HttpServletRequestMap(request));
|
||||
this.sessionMap = new LocalSharedAttributeMap(new HttpSessionMap(request));
|
||||
@@ -102,7 +114,7 @@ public class ServletExternalContext implements ExternalContext {
|
||||
public SharedAttributeMap getGlobalSessionMap() {
|
||||
return getSessionMap();
|
||||
}
|
||||
|
||||
|
||||
public SharedAttributeMap getApplicationMap() {
|
||||
return applicationMap;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ import org.springframework.webflow.core.collection.ParameterMap;
|
||||
import org.springframework.webflow.core.collection.SharedAttributeMap;
|
||||
|
||||
/**
|
||||
* Provides contextual information about a JSF environment that has interacted
|
||||
* with SWF.
|
||||
* Provides contextual information about a JSF environment that has interacted with SWF.
|
||||
*
|
||||
* @author Keith Donald
|
||||
*/
|
||||
@@ -50,19 +49,35 @@ public class JsfExternalContext implements ExternalContext {
|
||||
*/
|
||||
private String outcome;
|
||||
|
||||
/**
|
||||
* An accessor for the JSF request parameter map.
|
||||
*/
|
||||
private ParameterMap requestParameterMap;
|
||||
|
||||
/**
|
||||
* An accessor for the JSF request attribute map.
|
||||
*/
|
||||
private MutableAttributeMap requestMap;
|
||||
|
||||
/**
|
||||
* An accessor for the JSF session map.
|
||||
*/
|
||||
private SharedAttributeMap sessionMap;
|
||||
|
||||
/**
|
||||
* An accessor for the JSF application map.
|
||||
*/
|
||||
private SharedAttributeMap applicationMap;
|
||||
|
||||
/**
|
||||
* Creates a JSF External Context.
|
||||
* @param facesContext the JSF faces context
|
||||
*/
|
||||
public JsfExternalContext(FacesContext facesContext) {
|
||||
this.facesContext = facesContext;
|
||||
initMaps(facesContext);
|
||||
}
|
||||
|
||||
private ParameterMap requestParameterMap;
|
||||
private MutableAttributeMap requestMap;
|
||||
private SharedAttributeMap sessionMap;
|
||||
private SharedAttributeMap applicationMap;
|
||||
|
||||
/**
|
||||
* Creates a JSF External Context.
|
||||
* @param facesContext the JSF faces context.
|
||||
@@ -73,7 +88,14 @@ public class JsfExternalContext implements ExternalContext {
|
||||
this.facesContext = facesContext;
|
||||
this.actionId = actionId;
|
||||
this.outcome = outcome;
|
||||
|
||||
initMaps(facesContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes parameter and attribute maps from context data structures.
|
||||
* @param facesContext the faces context
|
||||
*/
|
||||
private void initMaps(FacesContext facesContext) {
|
||||
this.requestParameterMap = new LocalParameterMap(facesContext.getExternalContext().getRequestParameterMap());
|
||||
this.requestMap = new LocalAttributeMap(facesContext.getExternalContext().getRequestMap());
|
||||
this.sessionMap = new LocalSharedAttributeMap(new SessionSharedMap(facesContext));
|
||||
@@ -107,7 +129,7 @@ public class JsfExternalContext implements ExternalContext {
|
||||
public SharedAttributeMap getGlobalSessionMap() {
|
||||
return getSessionMap();
|
||||
}
|
||||
|
||||
|
||||
public SharedAttributeMap getApplicationMap() {
|
||||
return applicationMap;
|
||||
}
|
||||
@@ -133,6 +155,10 @@ public class JsfExternalContext implements ExternalContext {
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* An accessor of a JSF session map.
|
||||
* @author Keith Donald
|
||||
*/
|
||||
private static class SessionSharedMap extends SharedMapDecorator {
|
||||
|
||||
private FacesContext facesContext;
|
||||
@@ -147,6 +173,10 @@ public class JsfExternalContext implements ExternalContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An accessor of an JSF application map.
|
||||
* @author Keith Donald
|
||||
*/
|
||||
private static class ApplicationSharedMap extends SharedMapDecorator {
|
||||
|
||||
private FacesContext facesContext;
|
||||
|
||||
@@ -398,7 +398,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Returns the attribute in flash scope. Flash-scoped attributes are local to
|
||||
* the active flow session.
|
||||
* the active flow session and cleared on the next user event.
|
||||
* @param attributeName the name of the attribute
|
||||
* @return the attribute value
|
||||
*/
|
||||
@@ -408,7 +408,8 @@ public abstract class AbstractFlowExecutionTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Returns the required attribute in flash scope; asserts the attribute is
|
||||
* present. Flash-scoped attributes are local to the active flow session.
|
||||
* present. Flash-scoped attributes are local to the active flow session and cleared on
|
||||
* the next user event.
|
||||
* @param attributeName the name of the attribute
|
||||
* @return the attribute value
|
||||
* @throws IllegalStateException if the attribute was not present
|
||||
@@ -420,7 +421,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase {
|
||||
/**
|
||||
* Returns the required attribute in flash scope; asserts the attribute is
|
||||
* present and of the correct type. Flash-scoped attributes are local to the
|
||||
* active flow session.
|
||||
* active flow session and cleared on the next user event.
|
||||
* @param attributeName the name of the attribute
|
||||
* @return the attribute value
|
||||
* @throws IllegalStateException if the attribute was not present or was of
|
||||
|
||||
Reference in New Issue
Block a user