org.apache.struts2.components
类 Number

java.lang.Object
  继承者 org.apache.struts2.components.Component
      继承者 org.apache.struts2.components.ContextBean
          继承者 org.apache.struts2.components.Number

public class Number
extends ContextBean

Format Number object in different ways.

The number tag will allow you to format a Number in a quick and easy way, based on the java.text.NumberFormat class. There are four basic number types, a number, a currency, a percentage and an integer. If a currency is specified, the number format will match the given currency. Further parameters can be overridden as needed.

If a type is not defined, it will finally fall back to the default NumberFormat.getNumberInstance() formatting.

Note: If the requested Number object isn't found on the stack, a blank will be returned.

Configurable attributes are :-

Possible values for rounding mode are :-

Examples

  <!-- START SNIPPET: example -->
  <s:number name="invoice.total" type="currency" currency="XYZ" />
  <s:number name="invoice.quantity" type="number" />
  <s:number name="invoice.discount" type="percentage" />
  <s:number name="invoice.terms" type="integer" />
  <!-- END SNIPPET: example -->
 

Number


字段摘要
static String NUMBERTAG_PROPERTY
          Property name to fall back when no format is specified
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
Number(com.opensymphony.xwork2.util.ValueStack stack)
           
 
方法摘要
 boolean end(Writer writer, String body)
          Callback for the end tag of this component.
 String getCurrency()
           
 Integer getMaximumFractionDigits()
           
 Integer getMaximumIntegerDigits()
           
 Integer getMinimumFractionDigits()
           
 Integer getMinimumIntegerDigits()
           
 String getName()
           
 String getRoundingMode()
           
 String getType()
           
 Boolean isGroupingUsed()
           
 Boolean isParseIntegerOnly()
           
 void setCurrency(String currency)
           
 void setGroupingUsed(Boolean groupingUsed)
           
 void setMaximumFractionDigits(Integer maximumFractionDigits)
           
 void setMaximumIntegerDigits(Integer maximumIntegerDigits)
           
 void setMinimumFractionDigits(Integer minimumFractionDigits)
           
 void setMinimumIntegerDigits(Integer minimumIntegerDigits)
           
 void setName(String name)
           
 void setParseIntegerOnly(Boolean parseIntegerOnly)
           
 void setRoundingMode(String roundingMode)
           
 void setType(String type)
           
 
从类 org.apache.struts2.components.ContextBean 继承的方法
setId, setVar
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, addParameter, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, start, usesBody
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

NUMBERTAG_PROPERTY

public static final String NUMBERTAG_PROPERTY
Property name to fall back when no format is specified

另请参见:
常量字段值
构造方法详细信息

Number

public Number(com.opensymphony.xwork2.util.ValueStack stack)
方法详细信息

end

public boolean end(Writer writer,
                   String body)
从类 Component 复制的描述
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

覆盖:
Component 中的 end
参数:
writer - the output writer.
body - the rendered body.
返回:
true if the body should be evaluated again

setType

public void setType(String type)

setCurrency

public void setCurrency(String currency)

getName

public String getName()
返回:
Returns the name.

setName

public void setName(String name)

getType

public String getType()
返回:
Returns the format.

getCurrency

public String getCurrency()
返回:
Returns the currency.

setGroupingUsed

public void setGroupingUsed(Boolean groupingUsed)

isGroupingUsed

public Boolean isGroupingUsed()
返回:
Returns the grouping used.

getMaximumFractionDigits

public Integer getMaximumFractionDigits()
返回:
the maximumFractionDigits

setMaximumFractionDigits

public void setMaximumFractionDigits(Integer maximumFractionDigits)
参数:
maximumFractionDigits - the maximumFractionDigits to set

getMaximumIntegerDigits

public Integer getMaximumIntegerDigits()
返回:
the maximumIntegerDigits

setMaximumIntegerDigits

public void setMaximumIntegerDigits(Integer maximumIntegerDigits)
参数:
maximumIntegerDigits - the maximumIntegerDigits to set

getMinimumFractionDigits

public Integer getMinimumFractionDigits()
返回:
the minimumFractionDigits

setMinimumFractionDigits

public void setMinimumFractionDigits(Integer minimumFractionDigits)
参数:
minimumFractionDigits - the minimumFractionDigits to set

getMinimumIntegerDigits

public Integer getMinimumIntegerDigits()
返回:
the minimumIntegerDigits

setMinimumIntegerDigits

public void setMinimumIntegerDigits(Integer minimumIntegerDigits)
参数:
minimumIntegerDigits - the minimumIntegerDigits to set

isParseIntegerOnly

public Boolean isParseIntegerOnly()
返回:
the parseIntegerOnly

setParseIntegerOnly

public void setParseIntegerOnly(Boolean parseIntegerOnly)
参数:
parseIntegerOnly - the parseIntegerOnly to set

getRoundingMode

public String getRoundingMode()
返回:
the roundingMode

setRoundingMode

public void setRoundingMode(String roundingMode)
参数:
roundingMode - the roundingMode to set