You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-issues@incubator.apache.org by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org> on 2007/04/04 17:17:32 UTC

[jira] Created: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
---------------------------------------------------------------------------------------------------

                 Key: ADFFACES-438
                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
             Project: MyFaces ADF-Faces
          Issue Type: Bug
          Components: Components
    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
            Reporter: Martin Marinschek
         Assigned To: Martin Marinschek
             Fix For: 1.0.1-incubating-core-SNAPSHOT


Trinidad's components all call:

CoreRenderer.toUri()

 when they encode their resource-urls.

This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.

Changing toUri() method to:

  static public String toUri(Object o)
  {
    if (o == null)
      return null;
    
    String uri = o.toString();

    // Treat two slashes as server-relative
    if (uri.startsWith("//"))
    {
        uri = uri.substring(1);
    }

    return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
            FacesContext.getCurrentInstance(),uri);
  }

should fix the issue.

regards,

Martin



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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Scott O'Bryan (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486703 ] 

Scott O'Bryan commented on ADFFACES-438:
----------------------------------------

One more comment.  DO NOT get the resource URL using the viewHandler.  It's far safer to use ExternalContext.encodeResourceURI so that we can support Portlet Bridges going forward.

Scott

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Resolved: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Marinschek resolved ADFFACES-438.
----------------------------------------

    Resolution: Fixed

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Scott O'Bryan (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486701 ] 

Scott O'Bryan commented on ADFFACES-438:
----------------------------------------

We have to be very careful about doing this.  In ADF_Faaces 10.1.3.2 (the code which became trinidad), doing this resulted in "doubly encoded" and "wrongly encoded" URL's...  And there are a few exceptions where URL's shouldn't be encoded at all.  If someone wants to take on this task, make sure that the enhancements work as-is with all the current golden files.

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486813 ] 

Martin Marinschek commented on ADFFACES-438:
--------------------------------------------

I found a way to fix this once and for all - part of the solution was to change the mock-objects of the test to something the golden-files expected.

regards,

Martin

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486717 ] 

Martin Marinschek commented on ADFFACES-438:
--------------------------------------------

Scott, ExternalContext.encodeResourceURI is called _after_ the ViewHandler call in all JSF components in the standard. So first ViewHandler.getResourceUrl, then externalContext.encodeResourceURI(). It's a two step process.

See e.g. the rendering code in ImageRenderer - first the CoreRenderer.toUri() method is called (which would map to ViewHandler.getResourceUrl()), then CoreRenderer.renderEncodedResourceURI() is called (which would map to ExternalContext.encodeResourceURI in the standard).

Anyways you're right in that a test fails with my first code snippet - I'm digging into it.

As a reference, the toUri and the ViewHandler.getResourceUrl methods.

regards,

Martin

toUri:

    if (o == null)
      return null;
    
    String uri = o.toString();
    if (uri.startsWith("/"))
    {
      // Treat two slashes as server-relative
      if (uri.startsWith("//"))
      {
        uri = uri.substring(1);
      }
      else
      {
        FacesContext fContext = FacesContext.getCurrentInstance();
        uri = fContext.getExternalContext().getRequestContextPath() + uri;
      }
    }

    return uri;

getResourceUrl():

        if (path.length() > 0 && path.charAt(0) == '/') {
            return facesContext.getExternalContext().getRequestContextPath() + path;
        }
        else {
            return path;
        }

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486726 ] 

Martin Marinschek commented on ADFFACES-438:
--------------------------------------------

Hi *,

I've looked through the test results - I'll post one of the failures (the one for image, e.g.) here:

original golden file:

      <img
           id="mainId"
           name="mainId"
           src="uri-attr:encoded-resource-url:/test-context-path/bogus/image/uri"
          >
        
      </img>

outcome after my potential change:

      <img
           id="mainId"
           name="mainId"
           src="uri-attr:encoded-resource-url:resource-url:/bogus/image/uri"
          >
        
      </img>

I conclude from my previous comments that the sources of the golden files are bogus - resource-url needs to be called before encoded-resource-url is called, so the golden files sources are wrong.

two problems remain with my approach:

1) toUri is used all over now, in fact there should be a toResourceUri and a toActionUri cause these two might be handled differently.

2) the question is if toUri is ever called where a FacesContext is not available - if yes, my approach would fail.

regards,

Martin





> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Scott O'Bryan (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486725 ] 

Scott O'Bryan commented on ADFFACES-438:
----------------------------------------

Hey Martin,

Thanks for explaining.  I didn't catch what you were talking about (although I thought I did).  I'm trying to be a little "zen" about the URL's because there is no real OpenSource environment with which to test this stuff in the Portal probably until the release of JSR-301.  So I'm trying to make sure the resulting URL's are true in my "Proof of Concept" environment so the trasition to support JSR-301 will be a painless one.

Scott

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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


[jira] Commented: (ADFFACES-438) Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this

Posted by "Martin Marinschek (JIRA)" <ad...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/ADFFACES-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486727 ] 

Martin Marinschek commented on ADFFACES-438:
--------------------------------------------

Sure Scott, no problem!

regards,

Martin

> Trinidad components don't use ViewHandler.getResourceUrl - custom ViewHandlers can fail due to this
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ADFFACES-438
>                 URL: https://issues.apache.org/jira/browse/ADFFACES-438
>             Project: MyFaces ADF-Faces
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.0.1-incubating-core-SNAPSHOT
>            Reporter: Martin Marinschek
>         Assigned To: Martin Marinschek
>             Fix For: 1.0.1-incubating-core-SNAPSHOT
>
>
> Trinidad's components all call:
> CoreRenderer.toUri()
>  when they encode their resource-urls.
> This method does essentially the same as the JSF-Viewhandler's method getResourceUrl(), so there is no reason why the core-renderer shouldn't call this method. If the viewHandler's getResourceUrl() is not called, some other projects fail to work together with Trinidad, an example for this is Weblets by John Fallows which overwrites the ViewHandler's getResourceUrl() method.
> Changing toUri() method to:
>   static public String toUri(Object o)
>   {
>     if (o == null)
>       return null;
>     
>     String uri = o.toString();
>     // Treat two slashes as server-relative
>     if (uri.startsWith("//"))
>     {
>         uri = uri.substring(1);
>     }
>     return FacesContext.getCurrentInstance().getApplication().getViewHandler().getResourceURL(
>             FacesContext.getCurrentInstance(),uri);
>   }
> should fix the issue.
> regards,
> Martin

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