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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:09:04+00:00 2026-05-21T18:09:04+00:00

I have a strange situation where i the f:convertNumber doesnt work when trying to

  • 0

I have a strange situation where i the f:convertNumber doesnt work when trying to store it to a untyped Map.

I expect the number to be stored as a java.lang.Double object in the Map.


Here’s the xhtml excerpt :

<h:inputText value="#{tInputBean.generalMap['myNumber']}" id="testNumber">
    <f:convertNumber />
</h:inputText>
<p:message for="testNumber" />

And here’s the bean :

@Named("tInputBean")
@Scope("view")
public class TInputBean {
    private Log log = LogFactory.getLog(TInputBean.class);
    private Map generalMap = new HashMap();

    // .. and the setter getter
    ....
}

And here’s my log :

DEBUG PhaseTracker - BEFORE PHASE RESTORE_VIEW 1
DEBUG PhaseTracker - AFTER PHASE RESTORE_VIEW 1
DEBUG PhaseTracker - BEFORE PHASE APPLY_REQUEST_VALUES 2
DEBUG DebugUtil - ============== start debugMap parameter map : ==============
DEBUG DebugUtil - testNumber='123123123'
DEBUG DebugUtil - javax.faces.partial.execute='SaveHeader testNumberPanel RPBPanel'
DEBUG DebugUtil - SaveHeader='SaveHeader'
DEBUG DebugUtil - javax.faces.partial.render='messages RPBPanel DebugVersionHeader testNumberPanel'
DEBUG DebugUtil - javax.faces.source='SaveHeader'
DEBUG DebugUtil - j_idt42='j_idt42'
DEBUG DebugUtil - javax.faces.ViewState='7088371747667351331:-3641627426454744246'
DEBUG DebugUtil - transNum='TRX003'
DEBUG DebugUtil - javax.faces.partial.ajax='true'
DEBUG DebugUtil - ============== end debugMap parameter map : ==============
DEBUG PhaseTracker - AFTER PHASE APPLY_REQUEST_VALUES 2
DEBUG PhaseTracker - BEFORE PHASE PROCESS_VALIDATIONS 3
DEBUG PhaseTracker - AFTER PHASE PROCESS_VALIDATIONS 3
DEBUG PhaseTracker - BEFORE PHASE RENDER_RESPONSE 6
DEBUG PhaseTracker - AFTER PHASE RENDER_RESPONSE 6

And after the render, <p:message for="testNumber" /> is replaced with : {0}: Conversion error occurred.


The things i notice is :

  1. There’s no exception happening while the conversion error occurs. Nothing is handled by my exceptionhandler which captures and log all exceptions. No exception trace.
  2. I cannot specify a type like java.lang.Double in the <f:convertNumber> tag.

Should i make my own converter for this to work ? Im already imagining things like :

<h:inputText value="#{tInputBean.generalMap['myNumber']}" id="testNumber">
    <f:converter type="MyDoubleConverter" />
</h:inputText>
<p:message for="testNumber" />

Please share your opinion on this matter.
Thank you !


UPDATE


I’ve built a simple converter that suits my need, and so far it’s been working ok. Here’s the code, please share your opinion on this :

@FacesConverter(value="Double")
public class DoubleConverter implements Converter {
    private Log log = LogFactory.getLog(DoubleConverter.class);

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        //log.debug("locale : " + context.getViewRoot().getLocale());
        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(context.getViewRoot().getLocale());
        //log.debug("VALUE == " + value);
        String result = value == null || value.toString().trim().length() == 0 ? null : format.format(value);
        //log.debug("RESULT == " + value);
        return result;
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        //log.debug("locale : " + context.getViewRoot().getLocale());
        //log.debug("STRING VALUE == " + value);
        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(context.getViewRoot().getLocale());
        try {
            Object result = ((value == null) || (value.trim().length() == 0)) ? null : format.parse(value).doubleValue();
            //log.debug("RESULT == " + result);
            return result;
        } catch (Exception e) {
            log.error(e,e);
            throw new ConverterException(e);
        }
    }
}

And here’s how my jsf make use of it :

<h:inputText value="#{tInputBean.generalMap['myNumber']}" 
   id="testNumber" converter="Double"/>
<p:message for="testNumber" />
  • 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-21T18:09:04+00:00Added an answer on May 21, 2026 at 6:09 pm

    Finally i made my own simple converter for this purpose, and the code has been posted at the bottom of the original post.

    Thank you !

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

Sidebar

Related Questions

No related questions found

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.