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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:28:47+00:00 2026-06-06T02:28:47+00:00

How to set a bean property from jsf page before executing this f:event listener:

  • 0

How to set a bean property from jsf page before executing this f:event listener:

    <f:event type="preRenderComponent" listener="bean.method}"/>

I tried the below code but it does not set the value to the bean property.

    <f:event type="preRenderComponent" listener="bean.method}">
        <f:setPropertyActionListener target="#{bean.howMany}" value="2"/>
    </f:event>

JSF2.1.6 with PF 3.3


EDIT

Any issues with this below code? (This works! but I just want to confirm if there are any issues with this!?)

<f:event type="preRenderComponent" listener="#{bean.setHowMany(15)}"/> 
<f:event type="preRenderComponent" listener="#{bean.method}"/>
  • 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-06T02:28:51+00:00Added an answer on June 6, 2026 at 2:28 am

    try

    <f:event type="preRenderComponent" listener="#{bean.method('2')}"/>
    

    And if that wont work , try

    <f:event type="preRenderComponent" listener="#{bean.method}">
        <f:attribute name="howMany" value="2" />
    </f:event>
    

    and in you managed bean add the following

    public void method(ComponentSystemEvent event) {
        String howMany = (String) event.getComponent().getAttributes().get("howMany");
    }
    

    I think you better avoid two subsequent <f:event> calls , when you don’t really need them, Although I think i saw somewhere that the order of declaration will be the order of execution, It still may vary between different JSF implementation and you never can be 100% sure that you can count on it…

    so INMO using only one is better in this case

    <f:event type="preRenderComponent" listener="#{bean.method(15)}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is from Spring documentation , section 9.5.4 <bean id=myAdvisor class=com.mycompany.MyAdvisor> <property name=someProperty value=Custom
Is it possible to use the property of one Spring bean to set the
SET @v1 := SELECT COUNT(*) FROM user_rating; SELECT @v1 When I execute this query
I need to instantiate a session bean from another request scoped bean & set
Is there a way to set a property of a bean in a Spring
I have a JSF ManagedBean which has a property that should be set by
Does it set a flag in a bean ? Does it load special bean
Set<Type> union = new HashSet<Type>(s1); union.addAll(s2); AND Set <Type> union = new HashSet<Type>(); union.addAll(s1);
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
I'm new to JSF, so this question might be strange. I have an inputText

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.