Further to this I have delved into WriteTag.java, and see the following code in 
formatValue():


// Try to retrieve format string from resources by the key from formatKey.
if( ( formatString==null ) && ( formatKey!=null ) ) {
  formatString = retrieveFormatString( this.formatKey );
  if( formatString!=null )
    formatStrFromResources = true;
}

// Prepare format object for numeric values.
if ( value instanceof Number ) {

  if( formatString==null ) {
    if( ( value instanceof Byte )    ||
        ( value instanceof Short )   ||
        ( value instanceof Integer ) ||
        ( value instanceof Long )    ||
        ( value instanceof BigInteger ) )
      formatString = retrieveFormatString( INT_FORMAT_KEY );
    else if( ( value instanceof Float ) ||
             ( value instanceof Double ) ||
             ( value instanceof BigDecimal ) )
      formatString = retrieveFormatString( FLOAT_FORMAT_KEY );
      if( formatString!=null )
       formatStrFromResources = true;
}


if( formatString!=null ) {
  try {
    format = NumberFormat.getNumberInstance( locale );
    if( formatStrFromResources )
      ( ( DecimalFormat ) format ).applyLocalizedPattern( formatString );
    else
( ( DecimalFormat ) format ).applyPattern( formatString );
  } catch( IllegalArgumentException _e ) {
    JspException e = new JspException(messages.getMessage("write.format", 
formatString));
    RequestUtils.saveException(pageContext, e);
    throw e;
  }


The formatStrFromResources String is set true if the formatString was successfuly obtained from the resources list. It then calls applyLocalizedPattern(), passing the format String that was obtained from the resources.

But AFAICS, if the formatString obtained from the app resources bundle is NOT appropriate for the locale then the call to applyLocalizedPattern() will fail. And indeed in my test case the formatString is not appropriate for the locale - it is the default formatString that is retrieved no specific resource for the locale is found.


So, it seems to me that the above code must always fail if the formatString is present at all in resources bundle. To make it work the retrieveFormatString() must return null if the formatString is not defined FOR THE LOCALE.


Or am I missing something fundamental?

Any insight gratefully receieved - this is driving me nuts.


TIA - Adam











Adam Lipscombe wrote:
Thanks for this.

The stack trace is below. The global.moneyFormat property is defined in the app resources file as #,##0.00. The client had a Portuguese locale set, which I believe has a currency format of #.##0,00.

As you say, I would expect the system to look for a resources file that is specific to the Portuguese locale, and it cannot find one, revert to standard.


Any ideas?



Thanks - Adam





ApplicationDispatcher[/ExpenSysWT]: Servlet.service() for servlet debugjsp threw exception
javax.servlet.jsp.JspException: Wrong format string: '#,##0.00'
at org.apache.struts.taglib.bean.WriteTag.formatValue(WriteTag.java:376)
    at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:292)
at org.apache.jsp.pages.pec.Pec_jsp._jspx_meth_bean_write_26(Pec_jsp.java:6518)
    at org.apache.jsp.pages.pec.Pec_jsp._jspService(Pec_jsp.java:3746)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.expensys.expensyswt.struts.filters.TimeoutFilter.doFilter(TimeoutFilter.java:184) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.expensys.expensyswt.struts.filters.AvailabilityFilter.doFilter(AvailabilityFilter.java:130) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:534)



Laurie Harper wrote:

No, it should work as you expect. What's the full stack trace (including root cause)?

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--

________________________________
Adam Lipscombe
Escalus Software Systems
[EMAIL PROTECTED]
Tel: 08450 170 850
www.expensys.com

This email and any files transmitted with it, including replies and
forwarded copies, may contain privileged and confidential information and
is intended solely for the person or organisation to whom it is addressed.
If you have received this communication in error, please notify us by email
([EMAIL PROTECTED]) or telephone (+44 (0)8450 170 850) and then delete the
email and any copies of it. Views or opinions expressed by an individual
within this email may not necessarily reflect the views of Escalus Software
Systems Ltd.

Although most emails and attachments from Escalus Software Systems Ltd are
screened, it is the responsibility of the recipient to ensure
that they are virus free. Escalus Software Systems Ltd will not accept any
liability for damage caused by a virus.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to