You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-user@portals.apache.org by Jason Novotny <no...@aei.mpg.de> on 2004/01/02 20:07:09 UTC

localization support in getResource method

    Hi,

    In WebSphere Portlet API, there is a very useful method available in 
the PortletContext for including localized JSP/HTML files-- I just 
pulled from the PortletContext class itself, the following javadoc:

/**
     * Returns the resource located at the given path as an InputStream 
object.
     * The data in the InputStream can be of any type or length.
     * The method returns null if no resource exists at the given path.
     *
     * To access protected resources the path has to be prefixed with 
/WEB-INF/
     * (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct 
path is
     * used. (e.g. /myportlet/myportlet.jsp).
     *
     * This method is enabled for multi-language and multi-device support.
     * For example, a jsp file "/myportlet/mytemplate.jsp" will be 
searched for
     * in the following order, when accessing via HTML-Browser:
     *
     * 1. /myportlet/html/en_US/mytemplate.jsp
     * 2. /myportlet/html/en/mytemplate.jsp
     * 3. /myportlet/html/mytemplate.jsp
     * 4. /myportlet/mytemplate.jsp
     *
     * @param path the path to the resource
     * @param client the client
     * @param locale the locale
     * @return the input stream
     */
    public InputStream getResourceAsStream(String path, Client client, 
Locale locale);

    How can I do something like this using the JSR 168 portlet API? It 
would seem I would have to perform my own internal logic I guess....

    Thanks, Jason



Re: localization support in getResource method

Posted by Stefan Hepper <st...@hursley.ibm.com>.
The JSR 168 EG decided to stick to the normal servlet API include 
pattern and therefore this feature did not make it into the JSR 168 API.
So you need to write your own code to simulate this functionality.

Stefan

Jason Novotny wrote:

> 
>    Hi,
> 
>    In WebSphere Portlet API, there is a very useful method available in 
> the PortletContext for including localized JSP/HTML files-- I just 
> pulled from the PortletContext class itself, the following javadoc:
> 
> /**
>     * Returns the resource located at the given path as an InputStream 
> object.
>     * The data in the InputStream can be of any type or length.
>     * The method returns null if no resource exists at the given path.
>     *
>     * To access protected resources the path has to be prefixed with 
> /WEB-INF/
>     * (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct 
> path is
>     * used. (e.g. /myportlet/myportlet.jsp).
>     *
>     * This method is enabled for multi-language and multi-device support.
>     * For example, a jsp file "/myportlet/mytemplate.jsp" will be 
> searched for
>     * in the following order, when accessing via HTML-Browser:
>     *
>     * 1. /myportlet/html/en_US/mytemplate.jsp
>     * 2. /myportlet/html/en/mytemplate.jsp
>     * 3. /myportlet/html/mytemplate.jsp
>     * 4. /myportlet/mytemplate.jsp
>     *
>     * @param path the path to the resource
>     * @param client the client
>     * @param locale the locale
>     * @return the input stream
>     */
>    public InputStream getResourceAsStream(String path, Client client, 
> Locale locale);
> 
>    How can I do something like this using the JSR 168 portlet API? It 
> would seem I would have to perform my own internal logic I guess....
> 
>    Thanks, Jason
> 
> 
>