Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:53:10+00:00 2026-06-17T07:53:10+00:00

I use the <p:media> to display static PDF content. <p:media value=/resource/test.pdf width=100% height=300px player=pdf>

  • 0

I use the <p:media> to display static PDF content.

<p:media value="/resource/test.pdf" 
         width="100%" height="300px" player="pdf">  
</p:media>

How can I change it to display dynamic content?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:53:11+00:00Added an answer on June 17, 2026 at 7:53 am

    Like as in <p:graphicImage>, the value attribute can point to a bean property returning StreamedContent. This only requires a special getter method for the reasons which is explained in detail in the following answer on using <p:graphicImage> with a dynamic resource from a database: Display dynamic image from database with p:graphicImage and StreamedContent.

    In your particular example, it would look like this:

    <p:media value="#{mediaManager.stream}" width="100%" height="300px" player="pdf">
        <f:param name="id" value="#{bean.mediaId}" />
    </p:media>
    

    With

    @ManagedBean
    @ApplicationScoped
    public class MediaManager {
    
        @EJB
        private MediaService service;
    
        public StreamedContent getStream() throws IOException {
            FacesContext context = FacesContext.getCurrentInstance();
    
            if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
                // So, we're rendering the HTML. Return a stub StreamedContent so that it will generate right URL.
                return new DefaultStreamedContent();
            } else {
                // So, browser is requesting the media. Return a real StreamedContent with the media bytes.
                String id = context.getExternalContext().getRequestParameterMap().get("id");
                Media media = service.find(Long.valueOf(id));
                return new DefaultStreamedContent(new ByteArrayInputStream(media.getBytes()));
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use media queries on a page http://test.lovecpokladu.cz/detail-mince?id=2461 like this: @media all and (min-width:
I use media player control to play mp3 files in asp.net application. I want
I have an iFrame that I use to display different media types by setting
I am trying to use Windows.Media.Capture.CameraCaptureUI() of Metro Style app in WPF application in
In our app, we use javax.media.JAI library to scale and improve image But sometimes
Java Message Service book by O'Reilly Media says: use request/reply model in point-to-point messaging.
I am trying to use a cursor with a managed query to filter media
I'm trying to evaluate the use of Windows Azure storage/media/cdn services to host the
I use below code to get photo's path and id: String[] projection = {MediaStore.Images.Media._ID,
I try to use Django sorl-thumbnail but it does not display images (and does't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.