shale-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Rivera (JIRA)" <j...@apache.org>
Subject [jira] Created: (SHALE-476) prerender not called for SESSION Scope ViewControllers
Date Sat, 03 Nov 2007 03:32:40 GMT
prerender not called for SESSION Scope ViewControllers
------------------------------------------------------

                 Key: SHALE-476
                 URL: https://issues.apache.org/struts/browse/SHALE-476
             Project: Shale
          Issue Type: Bug
          Components: View
    Affects Versions: 1.0.4
         Environment: Windows XP, Tomcat 6.6., Java 5, Eclipse 3.3
            Reporter: Paul Rivera


Hi,

If you set your ViewController to anything other than REQUEST scope, your prerender() method
does not get called.   Below is a code snippet from the ViewPhaseListener.beforeRenderResponse(PhaseEvent
event) method:

[code]
        Map map = event.getFacesContext().getExternalContext().getRequestMap();
        String viewName = (String) map.get(FacesConstants.VIEW_NAME_RENDERED);
        if (viewName == null) {
            return;
        }
        Object vc = map.get(viewName);  //--> only gets from the RequestMap
        if (vc == null) {
            return;
        }

        try {
            getViewControllerCallbacks(event.getFacesContext()).prerender(vc);
        } catch (Exception e) {
            handleException(event.getFacesContext(), e);
        }
        map.remove(FacesConstants.VIEW_NAME_RENDERED);
[/code]

In the code above, it vc is only looked-up in the request map.  It doesn't look into the session
map nor in the application map anymore.  Here is my proposed fix:

[code]
        Map map = event.getFacesContext().getExternalContext().getRequestMap();
        String viewName = (String) map.get(FacesConstants.VIEW_NAME_RENDERED);
        if (viewName == null) {
            return;
        }
        Object vc = map.get(viewName);
        //Check if the view is in the session scope.  Session scope attributes
        //will be prioritized over Application scope attributes.
        /*
        if (vc == null) {
            map = event.getFacesContext().getExternalContext().getSessionMap();
            vc = map.get(viewName);
        }
        
        //If the attribute is not in the Session scope, check if it is in the
        //Application scope.
        if (vc == null) {
            map = event.getFacesContext().getExternalContext().getApplicationMap();
            vc = map.get(viewName);
        }*/

        if (vc == null) {
            return;
        }

        try {
            getViewControllerCallbacks(event.getFacesContext()).prerender(vc);
        } catch (Exception e) {
            handleException(event.getFacesContext(), e);
        }
        map.remove(FacesConstants.VIEW_NAME_RENDERED);
[/code]

I've been using shale-view-1.0.4.jar with the fix in my web application and things look good
so far.  Please let me know if this is really a bug.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message