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

The Archive Base Latest Questions

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

I have a JSF Beans structure of this sort: @ManagedBean @ViewScoped public class ViewBeany

  • 0

I have a JSF Beans structure of this sort:

@ManagedBean
@ViewScoped
public class ViewBeany implements Serializable {

....
    @ManagedProperty(value='#{sessionBeany})
    transient private SessionBeany sessionBeany;
...

    public getSessionBeany() { ... };
    public setSessionBeany(SessionBeany sessionBeany) { ... };

}

The reason for the transient is that the session bean has some non-Serializable members and cannot be made Serializable.

Will this work?
If not, How can I solve the problem of not being able to serialize SesionBeany but having to keep it as a managed property under a view scoped bean?

Thanks!

  • 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-17T00:53:12+00:00Added an answer on June 17, 2026 at 12:53 am

    This won’t work. If the view scoped bean is serialized, all transient fields are skipped. JSF doesn’t reinject managed properties after deserialization, so you end up with a view scoped bean without a session scoped bean property which will only cause NPEs.

    In this particular construct, your best bet is to introduce lazy loading in the getter and obtain the session bean by the getter instead of by direct field access.

    private transient SessionBeany sessionBeany;
    
    public SessionBeany getSessionBeany() { // Method can be private.
        if (sessionBeany == null) {
            FacesContext context = FacesContext.getCurrentInstance();
            sessionBeany = context.getApplication().evaluateExpressionGet(context, "#{sessionBeany}", SessionBeany.class);
        }
    
        return sessionBeany;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I have a session bean <managed-bean> <managed-bean-name>vdcAddBean</managed-bean-name> <managed-bean-class>com.cloud.appsportfolio.jsf.vdc.beans.VDCAddBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> Now, I am injecting
I use this code in the JSF page <h:outputText value=#{writeBean.t} /> (and I have
I have the following confguration in my JSF Spring application: <bean id=userSessionBean class=com.vanilla.beans.UserSessionBean scope=session>
i have a JSF web application. I use Beans as Spring Beans (not JSF
I have a JSF data table <h:dataTable id=memberTable value=#{bean.pList} border=0 rowClasses=rowEven rowOdd var=item> <h:column
Suppose i have JSF page <h:body> <h:form id=formID prependId=false> <h:outputText id=randomID value=#{randomNumber.random}/> <h:commandButton id=buttonID
I have a JSF webapp with some standard JSF pages and backing beans. I
I am new to JSF and managed beans. I have a managed bean with
I have problem with JSF beans using Spring managed services. I got an error

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.