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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:00:18+00:00 2026-05-16T17:00:18+00:00

This converter is called from my JSF. I already register it inside faces-config.xml public

  • 0

This converter is called from my JSF. I already register it inside faces-config.xml

public class ProjectConverter implements Converter{

    @EJB
    DocumentSBean sBean;

    @ManagedProperty(value="#{logging}")
    private Logging log;    

    public ProjectConverter(){
    }

    public Object getAsObject(FacesContext context, UIComponent component, String value) 
    {
        if(value.trim().equals("")){
            return null;
        }
        return sBean.getProjectById(value);

    }

    public String getAsString(FacesContext context, UIComponent component, Object value) 
    {
        if(value == null){
            return null;
        }
        return String.valueOf(((Project) value).getId());
    }
}

I ran into java.lang.NullPointerException, when I am in getAsObject(), the primary reason is because my Session Bean sBean is null. I dont know how to fix this, I need to access to my Session bean so that I can query from my database

  • 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-16T17:00:19+00:00Added an answer on May 16, 2026 at 5:00 pm

    As BalusC said, injection only works in managed beans. You can however declare your converter as a managed bean in your faces-config

    <managed-bean>
       <managed-bean-name>myConverter</managed-bean-name>
       <managed-bean-class>com.example.MyConverter</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    

    And later reference it in a jsf component with an el expression:

    <h:outputText value="#{myBean.value}" converter="#{myConverter}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this configuration for some reason Conver function of Custom Converter is not called
I have a class called Book; class Book { public string Name { get;
I have this function called ProperCase that takes a string, then converts the first
I have a piece of code that the ARC converter turned into this... //
I have a WPF UserControl with binding converters referenced like this: <UserControl x:Class=MyControl x:Name=MyControl
I'm new to JSF, so this question might be strange. I have an inputText
I have this test in my test base: public void WorksWithAreaUsers() { using (new
I wish I could write LINQ to Entity queries that called other functions: from
I am trying to @javax.naming.Inject a Spring 3 Bean called WtvrBean into a JSF
I'm trying to convert the C# code from this webpage to VB. Everything seems

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.