• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to display negative values within parenthesis?

 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the values to be within parenthesis when the values are negative and the values displayed normally.

Example:<display:column property="Rebate"
format="$ {0,number,###,###,###,###.00}" title="Total Amount"/>

This formatting will only result in $ 123.00

what if the value is negative?
It will result in $ -123.00

As we have <fmt:formatNumber type="number" pattern="#########"/> for <input> tags,how will we display it using <display:column>?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
display is not a standard JSP tag library. What is it? How can we help if you don't even tell us what libraries you are using?
 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>


These are the libraries used
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would have helped if you had posted a link to the displaytag home page at least. Still, it wasn't hard to google. And it wasn't hard to find the documentation for that tag. In which it says that the format attribute gets a string which is a MessageFormat string.

MessageFormat is a Java class, so look up its documentation. Hint: if you want to have different formats for different ranges of numbers then "choice" is the keyword for that. Check out the examples in the documentation.
 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how will I solve this issue?I did not understand
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: Look at the API documentation for Java. Surely you must already have a bookmark for that, I find it's very difficult to write Java without referring to the documentation.

Step 2: Find the documentation for the MessageFormat class. It's in the java.text package, I think, but at any rate there's an index you can look in (the "Index" link at the top of every page).

Step 3: Read that documentation (which has quite a few examples) and find the example which suits your question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic