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 7525857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:40:09+00:00 2026-05-30T03:40:09+00:00

I’m having difficulty finding support on this topic, because I know how to pass

  • 0

I’m having difficulty finding support on this topic, because I know how to pass parameters to a template. What I want to do is pass parameters to not be used as parameters to the template but to a component within the template.

For example, in primefaces, you can write the following logic to create a button:

<p:commandButton action="#{printBean.print}">
  <f:attribute name="report" value="report.jrxml" />
</p:commandButton>

This is all fine and good when I don’t need to pass parameters. However, I need to construct a template which allows me to specify parameters to pass to the report dynamically. My first attempt was to do the following:

<p:commandButton actionListener="#{printBean.print}">
  <f:attribute name="report" value="report.jrxml" />
  <ui:insert name="reportParams" />
</p:commandButton>

Which would allow me to use the template in the following manner:

<ui:decorate template="templates/report.xhtml" >
  <ui:define name="reportParams>
    <f:attribute name="reportParam1" value="paramVal1" />
    <f:attribute name="reportParam2" value="paramVal2" />
    <f:attribute name="reportParam3" value="paramVal3" />        
    ...
  </ui:define>
</ui:decorate>

However parameters passed in this way are not received in my action listener in printBean, yet parameter “report” is. I think the attributes passed in this way are interpreted to mean that it is referring to the ui:define tag, and not to be inserted in the template as I would want.

Is there an alternative way of achieving the same way? Keep in mind I’m using JSF 2.0 and primefaces, but not Seam or any added libraries and ideally I would not have to add any libraries to make it work.

I apologize if an answer to this question already exists, but it’s maddening searching for an answer to this question.

EDIT: The number of parameters is variable, meaning I can’t simply use ui:param and put the value of that parameter as an attribute value within the template, because there could be many such parameters.

  • 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-05-30T03:40:10+00:00Added an answer on May 30, 2026 at 3:40 am

    Use a composite component instead of a template.

    Create this file /resources/mycomponents/printReport.xhtml:

    <ui:component
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:cc="http://java.sun.com/jsf/composite"
        xmlns:p="http://primefaces.org/ui"
    >
        <cc:interface>
            <!-- No attributes. -->
        </cc:interface>
        <cc:implementation>
            ...
            <p:commandButton value="Print" action="#{printBean.print}" />
            ...
        </cc:implementation>
    </ui:component>
    

    Use it as follows:

    xmlns:my="http://java.sun.com/jsf/composite/mycomponents"
    ...
    <my:printReport>
        <f:attribute name="reportParam1" value="paramVal1" />
        <f:attribute name="reportParam2" value="paramVal2" />
        <f:attribute name="reportParam3" value="paramVal3" />
    </my:printReport>
    

    Rewrite the print method as follows:

    public void print() {
        UIComponent composite = UIComponent.getCurrentCompositeComponent(FacesContext.getCurrentInstance());
        String reportParam1 = (String) composite.getAttributes().get("reportParam1");
        String reportParam2 = (String) composite.getAttributes().get("reportParam2");
        String reportParam3 = (String) composite.getAttributes().get("reportParam3");
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.