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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:33:40+00:00 2026-06-17T20:33:40+00:00

I had this working before, but then I changed some things, and I can’t

  • 0

I had this working before, but then I changed some things, and I can’t get it to work again. I am trying to use my service tier to hit the database and get a correct object from my converter class, depending on what the user clicks. I inject the service property into my converter with spring. During debugging, I can see that the property gets sets properly. But then when I go to call getService, it is null.

@FacesConverter("PlaceConverter")

@SessionScoped
public class PlaceConverter implements Converter {

private SearchQueryService searchQueryService;

/**
 * @return the searchQueryService
 */
public SearchQueryService getSearchQueryService() {
    return searchQueryService;
}

/**
 * @param searchQueryService the searchQueryService to set
 */
public void setSearchQueryService(SearchQueryService searchQueryService) {
    this.searchQueryService = searchQueryService;
}

@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String submittedValue) {
        try {
            Criteria criteria = new Criteria();
            criteria.setId(Integer.parseInt(submittedValue));
            return getSearchQueryService().findPlaces(criteria).get(0);
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    return null;
}

@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object value) {
    ((Place) value).setCategory(" (" + ((Place) value).getCategory() + ")");
    return String.valueOf(((Place) value).getPlaceId());
}

}

<bean id="placeConverterBean" class="com.ghghg.converter.PlaceConverter">
    <property name="searchQueryService" ref="searchQueryServiceBean" />
</bean>
  • 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-17T20:33:41+00:00Added an answer on June 17, 2026 at 8:33 pm

    Dependency injection in a converter works only if the converter is declared as a managed bean by the dependency injection framework in question. E.g. JSF’s own @ManagedBean, or CDI’s @Named, or Spring’s @Component. You should remove the @FacesConverter altogether and reference the converter instance in EL scope instead of referencing it by the converter ID.

    Thus, so

    <h:inputXxx converter="#{placeConverter}" />
    

    or

    <f:converter binding="#{placeConverter}" />
    

    instead of

    <h:inputXxx converter="PlaceConverter" />
    

    or

    <f:converter converterId="PlaceConverter" />
    

    Your concrete problem suggests that you were referencing it by converter ID (thus, via @FacesConverter). This way you end up getting a converter instance without any injected dependencies.

    See also:

    • How to inject Spring bean into JSF converter

    As to the role of the converter itself, this is mandatory because HTML code is represented as one large string and HTTP request parameter values can only be represented as strings. Complex Java objects would otherwise be printed via Object#toString() like so com.example.Place@hashcode, making it unusable in the server side.

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

Sidebar

Related Questions

Strangely I had this working before but I reinstalled my system, upgraded to w7
So basically this code was working fine before. I had some computer issues and
I know what' im trying to do is simple. I had this working before
initially I used $.get(../../some url); It was working fine.But I had to change the
Ok this is a weird problem because I had it working before. So I
I had this working at some point, as I had a question about this
I had this sqlcmd snippet working in batch but when I converted to powershell,
Ok, so I had this working just fine before making a few controller additions
I had a connection working but something changed and now the data isn't showing
Had this working; at one stage. The problem is the following text is now

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.