You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by "Nicolas Dutertry (JIRA)" <je...@portals.apache.org> on 2007/03/09 13:01:24 UTC

[jira] Created: (JS2-660) Request attribute not available in jsp when using the JetspeedPowerTool

Request attribute not available in jsp when using the JetspeedPowerTool
-----------------------------------------------------------------------

                 Key: JS2-660
                 URL: https://issues.apache.org/jira/browse/JS2-660
             Project: Jetspeed 2
          Issue Type: Bug
    Affects Versions: 2.1
            Reporter: Nicolas Dutertry


The request attributes set in a portlet are not available inside a jsp after an "include" when the portlet is inserted in the header.vm with JetspeedPowerTool.

For example I have the foolowing code in a portlet doView :
    request.setAttribute("test", "hello");
    getPortletContext().getRequestDispatcher("/test.jsp").include(request, response);

test.jsp contains :
    ${test}

And in header.vm :
    $jetspeed.renderPortletEntity("testportlet", "portlets::TestPortlet")

The value of attribute "test" is not visible. It works fine if the portlet is included in a psml.

I suggest the following correction in the class org.apache.jetspeed.engine.servlet.ServletRequestImpl, in the method getAttribute(String) : 

Replace : 

    public Object getAttribute( String name )
    {
        Object value = null;

        // In parallel mode, first look up from the worker.

        Thread ct = Thread.currentThread();

        if (ct instanceof Worker)
        {
            value = CurrentWorkerContext.getAttribute(name);
        }
        ...

With : 

    public Object getAttribute( String name )
    {
        Object value = null;

        // In parallel mode, first look up from the worker.

        Thread ct = Thread.currentThread();

        if (ct instanceof Worker)
        {
            value = CurrentWorkerContext.getAttribute(name);
            if (null == value)
            {
                PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
                if (pr != null)
                {
                    value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
                            name));
                }
            }
        }
        ....

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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Updated: (JS2-660) Request attribute not available in jsp when using the JetspeedPowerTool

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
     [ https://issues.apache.org/jira/browse/JS2-660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Sean Taylor updated JS2-660:
----------------------------------

          Component/s: Aggregation
        Fix Version/s: 2.1.1
    Affects Version/s:     (was: 2.1)
                       2.1.1

> Request attribute not available in jsp when using the JetspeedPowerTool
> -----------------------------------------------------------------------
>
>                 Key: JS2-660
>                 URL: https://issues.apache.org/jira/browse/JS2-660
>             Project: Jetspeed 2
>          Issue Type: Bug
>          Components: Aggregation
>    Affects Versions: 2.1.1
>            Reporter: Nicolas Dutertry
>         Assigned To: David Sean Taylor
>             Fix For: 2.1.1
>
>
> The request attributes set in a portlet are not available inside a jsp after an "include" when the portlet is inserted in the header.vm with JetspeedPowerTool.
> For example I have the foolowing code in a portlet doView :
>     request.setAttribute("test", "hello");
>     getPortletContext().getRequestDispatcher("/test.jsp").include(request, response);
> test.jsp contains :
>     ${test}
> And in header.vm :
>     $jetspeed.renderPortletEntity("testportlet", "portlets::TestPortlet")
> The value of attribute "test" is not visible. It works fine if the portlet is included in a psml.
> I suggest the following correction in the class org.apache.jetspeed.engine.servlet.ServletRequestImpl, in the method getAttribute(String) : 
> Replace : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>         }
>         ...
> With : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>             if (null == value)
>             {
>                 PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
>                 if (pr != null)
>                 {
>                     value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
>                             name));
>                 }
>             }
>         }
>         ....

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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Assigned: (JS2-660) Request attribute not available in jsp when using the JetspeedPowerTool

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
     [ https://issues.apache.org/jira/browse/JS2-660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Sean Taylor reassigned JS2-660:
-------------------------------------

    Assignee: David Sean Taylor

> Request attribute not available in jsp when using the JetspeedPowerTool
> -----------------------------------------------------------------------
>
>                 Key: JS2-660
>                 URL: https://issues.apache.org/jira/browse/JS2-660
>             Project: Jetspeed 2
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Nicolas Dutertry
>         Assigned To: David Sean Taylor
>
> The request attributes set in a portlet are not available inside a jsp after an "include" when the portlet is inserted in the header.vm with JetspeedPowerTool.
> For example I have the foolowing code in a portlet doView :
>     request.setAttribute("test", "hello");
>     getPortletContext().getRequestDispatcher("/test.jsp").include(request, response);
> test.jsp contains :
>     ${test}
> And in header.vm :
>     $jetspeed.renderPortletEntity("testportlet", "portlets::TestPortlet")
> The value of attribute "test" is not visible. It works fine if the portlet is included in a psml.
> I suggest the following correction in the class org.apache.jetspeed.engine.servlet.ServletRequestImpl, in the method getAttribute(String) : 
> Replace : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>         }
>         ...
> With : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>             if (null == value)
>             {
>                 PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
>                 if (pr != null)
>                 {
>                     value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
>                             name));
>                 }
>             }
>         }
>         ....

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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Resolved: (JS2-660) Request attribute not available in jsp when using the JetspeedPowerTool

Posted by "David Sean Taylor (JIRA)" <je...@portals.apache.org>.
     [ https://issues.apache.org/jira/browse/JS2-660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Sean Taylor resolved JS2-660.
-----------------------------------

    Resolution: Fixed

I am checking Woonsan's patch, as his team has been doing in-depth parallel load testing and uncovered issues related to 660.
Summary:
- added getAttributeNames() method and removeAttribute() method for org.apache.jetspeed.engine.servlet.ServletRequestImpl.
- added cachedAttributes member to cache request attribute map.
   If no attribute is added, changed, or removed, the cached map will be used in jsp pages.
- added another routine for getting attribute in getAttribute() method.
  Because PortletRequestImpl class of pluto encodes the name of attribute before calling setAttribute(), we have to check the encoded name also.

I reviewed Nicolas's patch. It is close to Woonsan's code, but there is extra code (2 lines) from Nicolas... 
Not clear to me why this is needed, as "pr" is not used. Commenting out for now...

PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
if (pr != null)

Nicolas, could you please test and see if this works for you now?


> Request attribute not available in jsp when using the JetspeedPowerTool
> -----------------------------------------------------------------------
>
>                 Key: JS2-660
>                 URL: https://issues.apache.org/jira/browse/JS2-660
>             Project: Jetspeed 2
>          Issue Type: Bug
>          Components: Aggregation
>    Affects Versions: 2.1.1
>            Reporter: Nicolas Dutertry
>         Assigned To: David Sean Taylor
>             Fix For: 2.1.1
>
>
> The request attributes set in a portlet are not available inside a jsp after an "include" when the portlet is inserted in the header.vm with JetspeedPowerTool.
> For example I have the foolowing code in a portlet doView :
>     request.setAttribute("test", "hello");
>     getPortletContext().getRequestDispatcher("/test.jsp").include(request, response);
> test.jsp contains :
>     ${test}
> And in header.vm :
>     $jetspeed.renderPortletEntity("testportlet", "portlets::TestPortlet")
> The value of attribute "test" is not visible. It works fine if the portlet is included in a psml.
> I suggest the following correction in the class org.apache.jetspeed.engine.servlet.ServletRequestImpl, in the method getAttribute(String) : 
> Replace : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>         }
>         ...
> With : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>             if (null == value)
>             {
>                 PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
>                 if (pr != null)
>                 {
>                     value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
>                             name));
>                 }
>             }
>         }
>         ....

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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


[jira] Commented: (JS2-660) Request attribute not available in jsp when using the JetspeedPowerTool

Posted by "Woonsan Ko (JIRA)" <je...@portals.apache.org>.
    [ https://issues.apache.org/jira/browse/JS2-660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495519 ] 

Woonsan Ko commented on JS2-660:
--------------------------------

As far as I understand, the 'super.getAttribute("javax.portlet.request")' statement is just for checking if the request is in a portlet context or not.

IMHO, therefore, we don't need to check any more in the current worker context because the current worker context is already in portlet rendering stage.

However, the original implementation in the 'getAttributeInternal()' method still need to check it because the portal engine handles the request to set or unset some variables before the request is passed to portlet stages.

> Request attribute not available in jsp when using the JetspeedPowerTool
> -----------------------------------------------------------------------
>
>                 Key: JS2-660
>                 URL: https://issues.apache.org/jira/browse/JS2-660
>             Project: Jetspeed 2
>          Issue Type: Bug
>          Components: Aggregation
>    Affects Versions: 2.1.1
>            Reporter: Nicolas Dutertry
>         Assigned To: David Sean Taylor
>             Fix For: 2.1.1
>
>
> The request attributes set in a portlet are not available inside a jsp after an "include" when the portlet is inserted in the header.vm with JetspeedPowerTool.
> For example I have the foolowing code in a portlet doView :
>     request.setAttribute("test", "hello");
>     getPortletContext().getRequestDispatcher("/test.jsp").include(request, response);
> test.jsp contains :
>     ${test}
> And in header.vm :
>     $jetspeed.renderPortletEntity("testportlet", "portlets::TestPortlet")
> The value of attribute "test" is not visible. It works fine if the portlet is included in a psml.
> I suggest the following correction in the class org.apache.jetspeed.engine.servlet.ServletRequestImpl, in the method getAttribute(String) : 
> Replace : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>         }
>         ...
> With : 
>     public Object getAttribute( String name )
>     {
>         Object value = null;
>         // In parallel mode, first look up from the worker.
>         Thread ct = Thread.currentThread();
>         if (ct instanceof Worker)
>         {
>             value = CurrentWorkerContext.getAttribute(name);
>             if (null == value)
>             {
>                 PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
>                 if (pr != null)
>                 {
>                     value = CurrentWorkerContext.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
>                             name));
>                 }
>             }
>         }
>         ....

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


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org