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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:03:13+00:00 2026-05-11T22:03:13+00:00

I am getting the value of amount like 4567.00 , 8976.00 etc. Now while

  • 0

I am getting the value of amount like 4567.00 , 8976.00 etc. Now while dispalying this value in displaytag i would like to print it as $4567.00 instead of just 4567.00. How can i do that?
Provided i just want to use display tag. I can acheive the same thing using core:out tag.

$<core:out value="${variableInMyList}" />

Answer Found [ How i did it ]

Create a new class:

public class NumberFormatDecorator implements DisplaytagColumnDecorator{
    Logger logger = MyLogger.getInstance ( );

    public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException {        
        try
        {
            Object colVal = columnValue;
            if ( columnValue != null ){
                colVal = Double.parseDouble( (String)columnValue );
            }
            return colVal;
        }catch ( Exception nfe ){}
        logger.error( "Unable to convert to Numeric Format");
        return columnValue; // even if there is some exception return the original value
    }
}

now in display tag

<displaytag:column title="Amount" property="amount" decorator="com.rj.blah.utils.decorator.NumberFormatDecorator" format="$ {0,number,0,000.00}"/>

Note: we can use the MessageFormat in format attribute of displaytag:column

  • 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-11T22:03:13+00:00Added an answer on May 11, 2026 at 10:03 pm

    DisplayTab is not very JSTL or EL friendly, and doesn’t support that style of formatting. Instead, you need to extend the TableDecorator class and put a reference to it using the decorator attribute of the display:table tag.

    Your decorator subclass should define a getter method for your formatted currency column, something like:

    public class MyTableDecorator extends TableDecorator {
        public String getCurrency() {
            MyRowType row = getCurrentRowObject();
            return row.getCurrency.format();
        }
    }
    

    and

    <display:table name="myList" decorator="test.MyTableDecorator">
        <display:column property="myProperty" title="My Property"/>
        <display:column property="currency" title="Currency"/>
    </display:table>
    

    Alternatively, you can implement the DisplaytagColumnDecorator interface, and reference that decorator from the JSP:

    <display:table name="myList">
        <display:column property="myProperty" title="My Property"/>
        <display:column property="currency" title="Currency" decorator="test.MyColumnDecorator"/>
    </display:table>
    

    See the documentation for more information

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

Sidebar

Related Questions

I am getting the value from my JSON like so: $adarray = json_decode($addata); if($adarray->{'zone'}
How would i go about getting the value of a field in another language
We're getting a very intermittent (like every few weeks someone complains about this) primary
I've had a hard time sitting in front of UML and getting value out
I am getting a Value cannot be null error from the code below: @Html.Label(material.ExtendedGroup)
Hi need help getting repeated value from give array,below is the code which im
I am getting the value of a fckeditor with javascript to show in a
I am getting The value 'abc' is not valid for fieldName. as error message.
I am not getting the value of all the checkboxes selected. It just gives
hi from my db i am getting a value as string type and when

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.