Specify view-id for "Non-JSF" resources

Splash Forums PrettyFaces Users Specify view-id for "Non-JSF" resources

This topic contains 2 replies, has 3 voices, and was last updated by  0swald 5 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18247

    m2m
    Participant

    I noticed in the documentation that it is possible to specify non-jsf resources for view-id of a url-mapping.

    I have a servlet which serves an iText pdf, so has no associated JSP, or view of any kind.

    How can I use “pretty:monthly-report” in my JSF code:

    pretty-config.xml


    <url-mapping id="monthly-report" parentId="lang">
    <pattern value="/site/#{site}/report/#{month}/#{year}/report.pdf"/>
    <view-id value="/MonthlyReportServlet"/>
    </url-mapping>

    web.xml
    <servlet>
    <servlet-name>MonthlyReportServlet</servlet-name>
    <servlet-class>www.reporting.MonthlyReportServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>MonthlyReportServlet</servlet-name>
    <url-pattern>/MonthlyReportServlet</url-pattern>
    </servlet-mapping>

    #22298

    Yes, it should be possible to use the URL of a Servlet as a viewId in a mapping. Actually PrettyFaces just forwards the request to the viewId, so every URL that your container knows about should work.

    What exactly is your question? How you would use this mapping? You could for example use the <pretty:link> component to create a link to the URL.

    BTW: You don’t need to use a Servlet for this. You could also simply create your content in an URL action. See this article for details:

    http://ocpsoft.org/prettyfaces/serving-dynamic-file-content-with-prettyfaces/

    #22299

    0swald
    Participant

    Wow, shame on me! Being your fan for already two years, never read this article and used to code servlets for such sort of tasks :)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.