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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:43:28+00:00 2026-06-15T17:43:28+00:00

How can I pass JS value to attribute nested tag inside component? I have

  • 0

How can I pass JS value to attribute nested tag inside component?

I have this code:

<p:remoteCommand .....>
    <f:attribute name="galaxie" value="jstest()" />
</p:remoteCommand>

And my simple JS jstest function :

function jstest(){
    return "foo";
}

When I test attribute value for galaxie in backing bean I have jstest() not foo.

  • 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-15T17:43:29+00:00Added an answer on June 15, 2026 at 5:43 pm

    The <f:attribute> is a JSF tag which runs in the webserver during producing HTML code. JavaScript is a client side language which doesn’t run in webserver, but runs in the webbrowser after it has retrieved all the JSF-produced HTML code. Yet you seem to expect that they run “in sync”. This is thus not true.

    To achieve what you’ve had in mind, you basically need to provide <h:inputHidden> which is bound to a bean property and let JS fill it before the remote command request is been fired.

    E.g.

    <h:form id="form">
        <h:inputHidden id="galaxie" value="#{bean.galaxie}" />
        <p:remoteCommand ... onstart="$('#form\\:galaxie').val(jstest())" process="@form" ... />
    </h:form>
    

    Alternatively, much easier is to just pass it as remote command function argument which accepts a JS object representing the request parameter map. Given a

    <h:form>
        <p:remoteCommand name="foo" ... />
    </h:form>
    

    you could just do:

    foo({ galaxie: jstest() });
    

    You can collect it by @ManagedProperty or ExternalContext#getRequestParameterMap().


    Update: since PrimeFaces 3.3, the syntax for parameters in <p:remoteCommand> function has changed. If you’re using at least PrimeFaces 3.3, then the function call should look like this:

    foo([{ name: 'galaxie', value: jstest() }]);
    

    See also Pass parameter to p:remoteCommand from JavaScript.

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

Sidebar

Related Questions

I have a custom JSP tag with an url attribute. How can I pass
Can I pass value to Navigation Context like this: NavigationContext.QueryString[param1] = PARAM1; Is it
How can I pass attribute value from iframe to parent? I.e. iframe (frame1) has
Can I pass a value out of a javascript function and back to the
How can I pass a variable value from a template using JavaScript without using
How can I pass an object of a MyClass (C#) by Parameter-by-Value to a
How can I pass the result from a scalar [single row, single value] query
Hi can some one point me some guidance, i pretend to pass the value
Some C functions can modify the string value without that I pass the address
I'm generating a string of values (colors) like so: 'red|green|blue|yellow|orange|black' Can I pass this

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.