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

  • Home
  • SEARCH
  • 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 7984605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:19:43+00:00 2026-06-04T11:19:43+00:00

In a Facelet page that uses a Facelet Template like this: <h:head> <h:outputScript name=custom.js

  • 0

In a Facelet page that uses a Facelet Template like this:

<h:head>
    <h:outputScript name="custom.js" library="javascript" target="head"/>
</h:head>
<ui:composition template="../../WEB-INF/Template.xhtml">

</ui:composition>

How do you include a custom javascript? In the code above my custom.js is ignored because
of the ui:composition facelet tag.

I dont want to mess my page by putting my javascript in it so I am externalizing it in my resources
folder.

But how do I achieve my goal?

UPDATE:

I basically have this button and I wanted to add custom javascript on the oncomplete event of my primefaces button.

<p:commandButton value="Save"
        actionListener="#{memberManagedBean.save}"
        oncomplete="handleSaveNewMember(xhr, status, args)"
        update=":memberListForm:membersTable"
        process="@form" />

But instead of putting my code to it, I have externalize it to my custom.js

function handleSaveNewMember(xhr, status, args) {
    /*More Code*/
    addMemberDlg.hide();
}

But looking at the generated HTML for my button, my custom javascript codes are not included and only the function name is added.

<button id="createupdateform:j_idt18" oncomplete:function(xhr, status, args){handleSaveNewMember(xhr, status, args);}});return false;" type="submit"><span class="ui-button-text">Save</span></button>

Why do you think this is so?

UPDATE 2

You should insert the script inside the ui:define facelet tag not inside the ui:composition.

<ui:composition template="../../WEB-INF/Template.xhtml">
    <ui:define name="content">
        <h:outputScript name="showmembers.js" library="javascript" target="head"/>
    </ui:define>
</ui:composition>
  • 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-04T11:19:45+00:00Added an answer on June 4, 2026 at 11:19 am

    You can place it inside your <ui:composition

    <ui:composition template="../../WEB-INF/Template.xhtml">
        <h:outputScript name="custom.js" library="javascript" target="head"/>
    </ui:composition>
    

    or place <h:outputScript inside your Template.xhtml

    anyway the <h:head> better be placed in your Template.xhtml only…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CKEditor in my page. Like this <h:head> <title>Facelet Title</title> <script type=text/javascript
I have main page that looks like this: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html
in a JSF facelet page (.xhtml) I have this javascript code <script type=text/javascript> function
I'm having problems with creating a Facelet Composition Control (= custom tag). That's the
In my .xhtml page, I have the following form: <ui:composition xmlns:ui=http://java.sun.com/jsf/facelets template=./../template/CustomerTemplate.xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:f=http://java.sun.com/jsf/core
I have the follwing code inside a facelet page: <h:inputNumber value=bean.property> <f:convertNumber type=currency />
I am using JSF2 on Facelets. I define an <ui:param> in a page: <ui:composition
I have a pretty complex JSF page (we use JSF2 with facelet) in which
I have jsf application in which I have to use a facelet custom component
I would like to do some more learning of facelets. Now that Java is

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.