本文整理汇总了Java中javax.faces.convert.ConverterException类的典型用法代码示例。如果您正苦于以下问题:Java ConverterException类的具体用法?Java ConverterException怎么用?Java ConverterException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConverterException类属于javax.faces.convert包,在下文中一共展示了ConverterException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsObject
import javax.faces.convert.ConverterException; //导入依赖的package包/类
/**
* Conversion to server representation, so converting days to milliseconds.
* Prior to the conversion the input value is validated.
*/
@Override
public Object getAsObject(FacesContext context, UIComponent component,
String value) {
try {
// Checks if mandatory and not empty
new ParameterValueValidator().validate(context, component, value);
} catch (ValidatorException e) {
throw new ConverterException(e.getFacesMessage());
}
// Validation passed; so if the value is empty it's not mandatory
if (value == null || value.trim().length() == 0) {
return null;
} else {
Long durationInMs = DurationValidation.convertDurationToMs(context,
value);
if (durationInMs != null) {
return durationInMs.toString();
} else {
throw new ConverterException(
ParameterValueValidator.getFacesMessage(component,
context));
}
}
}
示例2: getAsString
import javax.faces.convert.ConverterException; //导入依赖的package包/类
/**
* Conversion to portal representation as String.
*/
@Override
public String getAsString(FacesContext context, UIComponent component,
Object object) {
if (object == null) {
return null;
}
String value = object.toString();
if (value.trim().length() == 0) {
return null;
}
long durationInMs;
try {
durationInMs = Long.parseLong(value);
} catch (NumberFormatException e) {
throw new ConverterException(
ParameterValueValidator.getFacesMessage(component, context));
}
long days = durationInMs / DurationValidation.MILLISECONDS_PER_DAY;
return String.valueOf(days);
}
示例3: getAsObject
import javax.faces.convert.ConverterException; //导入依赖的package包/类
/**
* Conversion to server representation, so converting currency to internal
* integer with cents format. Prior to the conversion the input value is
* validated.
*
* @param context
* JSF context.
* @param component
* Component which value will be processed.
* @param value
* Value.
*/
public Object getAsObject(FacesContext context, UIComponent component,
String value) {
final PriceConverter converter = getConverter(context);
try {
return converter.parse(value);
} catch (ParseException e) {
String msg = e.getMessage();
if (msg != null
&& msg.equals("ERROR_PRICEMODEL_INVALID_FRACTIONAL_PART")) {
throw new ConverterException(JSFUtils.getFacesMessage(
component, context,
BaseBean.ERROR_PRICEMODEL_INVALID_FRACTIONAL_PART));
}
throw new ConverterException(JSFUtils.getFacesMessage(component,
context, BaseBean.ERROR_PRICEMODEL_INPUT));
}
}
示例4: getAsObject
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Override
public Object getAsObject(
FacesContext context,
UIComponent component,
String value)
{
try
{
return super.getAsObject(context, component, value);
}
catch(ConverterException ce)
{
throw ConverterUtils.getIntegerConverterException(context,
component,
ce,
value,
CONVERT_MESSAGE_ID,
MAXIMUM_MESSAGE_ID,
_SHORT_MAX,
MINIMUM_MESSAGE_ID,
_SHORT_MIN);
}
}
示例5: _addConversionErrorMessage
import javax.faces.convert.ConverterException; //导入依赖的package包/类
private void _addConversionErrorMessage(
FacesContext context,
ConverterException ce,
Object value)
{
FacesMessage message = ce.getFacesMessage();
if (message == null)
{
Object label = _getLabel();
message = MessageFactory.getMessage(context,
CONVERSION_MESSAGE_ID,
new Object[]{label, value,
ce.getMessage()},
label);
}
else
{
message = _wrapMessage(message);
}
context.addMessage(getClientId(context), message);
}
示例6: getAsObject
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Override
public Object getAsObject(
FacesContext context,
UIComponent component,
String value)
throws ConverterException
{
Object number = super.getAsObject(context, component, value);
if (number == null) // bug 4137626
return null;
// this is causing issue TRINIDAD-690
number =
DateTimeConverter.__typeConvert(context, this, component, value, number);
return number;
}
示例7: getAsObject
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Override
public Object getAsObject(
FacesContext context,
UIComponent component,
String value)
{
try
{
return super.getAsObject(context, component, value);
}
catch(ConverterException ce)
{
throw ConverterUtils.getIntegerConverterException(context,
component,
ce,
value,
CONVERT_MESSAGE_ID,
MAXIMUM_MESSAGE_ID,
_BYTE_MAX,
MINIMUM_MESSAGE_ID,
_BYTE_MIN);
}
}
示例8: testGetAsObjectWithComma
import javax.faces.convert.ConverterException; //导入依赖的package包/类
/**
* Test for getting value with unescaped comma.
*
* @throws ParseException
*/
@Test
public void testGetAsObjectWithComma() throws ConverterException, ParseException {
UIComponent component = getComponent();
POService actual = (POService) converter.getAsObject(context,
component, poServiceAsStringWithComma);
Assert.assertEquals(actual.getKey(), 10001);
Assert.assertEquals(actual.getPictureUrl(),
"/image?type=SERVICE_IMAGE&serviceKey=10001");
Assert.assertEquals(actual.getProviderName(), "Fujitsu, INC.");
Assert.assertEquals(actual.getServiceName(),
"Hello Kitty November 6.66 1234:");
Assert.assertEquals(actual.getStatusSymbol(), "status_NOT_ACTIVE");
Assert.assertEquals(actual.getVersion(), 5);
}
示例9: doTestStrictNess
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Override
protected void doTestStrictNess(
MockFacesContext context,
MockUIComponentWrapper wrapper,
Locale locale,
String inputValue)
{
NumberConverter converter = getNumberConverter();
converter.setLocale(locale);
context.getViewRoot().setLocale(locale);
try
{
// ADF Converter is not lenient.
converter.getAsObject(context, wrapper.getUIComponent(), inputValue);
fail("Expected converter exception");
}
catch (ConverterException ce)
{
; // We expected a exception to occur
}
}
示例10: testCreatePricedParameterRowListCreateMissing
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Test
public void testCreatePricedParameterRowListCreateMissing()
throws ConverterException {
product.getPriceModel().setSelectedParameters(null);
int size = parameterList.size()
+ parameterWithOption.getParameterDefinition()
.getParameterOptions().size();
size--; // one parameter is of type string, must not be listed
List<PricedParameterRow> selectedParameters;
selectedParameters = PricedParameterRow.createPricedParameterRowList(
product, false, true, false, true, true);
Assert.assertEquals(size, selectedParameters.size());
for (PricedParameterRow row : selectedParameters) {
Assert.assertNotNull(row.getPricedParameter());
}
}
示例11: testCreatePricedParameterRowList_NotIncludeConfigurableOneTimeParams
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Test
public void testCreatePricedParameterRowList_NotIncludeConfigurableOneTimeParams()
throws ConverterException {
// Given product with two one time parameter, 1 configurable, 1 not
// configurable
VOService product = givenProductWithParams();
List<PricedParameterRow> selectedParameters;
// when
selectedParameters = PricedParameterRow.createPricedParameterRowList(
product, true, true, true, true, false);
// then
Assert.assertEquals(1, selectedParameters.size());
assertTrue(selectedParameters.get(0).isOneTimeParameter());
}
示例12: createPricedParameterRowListForSubscription
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Test
public void createPricedParameterRowListForSubscription()
throws ConverterException {
// Given product with two one time parameter, 1 configurable, 1 not
// configurable
VOService product = givenProductWithParams();
List<PricedParameterRow> selectedParameters;
// when
selectedParameters = PricedParameterRow
.createPricedParameterRowListForSubscription(product);
// then
Assert.assertEquals(1, selectedParameters.size());
assertTrue(selectedParameters.get(0).isOneTimeParameter());
Assert.assertNull(selectedParameters.get(0).getParameter().getValue());
}
示例13: createPricedParameterRowListForService
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Test
public void createPricedParameterRowListForService()
throws ConverterException {
// Given product with two one time parameter, 1 configurable, 1 not
// configurable
VOService product = givenProductWithParams();
List<PricedParameterRow> selectedParameters;
// when
selectedParameters = PricedParameterRow
.createPricedParameterRowListForService(product);
// then
Assert.assertEquals(1, selectedParameters.size());
assertTrue(selectedParameters.get(0).isOneTimeParameter());
Assert.assertEquals("d1", selectedParameters.get(0).getParameter()
.getValue());
}
示例14: getConvertedValue
import javax.faces.convert.ConverterException; //导入依赖的package包/类
@Override
public Object getConvertedValue(
FacesContext context,
UIComponent component,
Object submittedValue
) throws ConverterException
{
boolean valuePassThru = getValuePassThru(component, getFacesBean(component));
if (!valuePassThru)
{
return _convertIndexedSubmittedValue(context, component, submittedValue);
}
else
{
return super.getConvertedValue(context, component, submittedValue);
}
}
示例15: getConvertedValue
import javax.faces.convert.ConverterException; //导入依赖的package包/类
/**
* Converts a string value into the component's value
* @param context the FacesContext
* @param component the component
* @param newValue the unconverted string value
*/
@Override
public Object getConvertedValue(
FacesContext context,
UIComponent component,
Object submittedValue) throws ConverterException
{
FacesBean bean = getFacesBean(component);
Converter converter = getConverter(component, bean);
if (converter == null)
converter = getDefaultConverter(context, component, bean);
if (converter != null)
{
return converter.getAsObject(context,
component,
// due to the new "JSF2 empty value" parameters it can be the
// case the we actually have a NULL value here.
(submittedValue != null) ? submittedValue.toString() : null);
}
return submittedValue;
}