當前位置: 首頁>>代碼示例>>Java>>正文


Java Converter類代碼示例

本文整理匯總了Java中javax.faces.convert.Converter的典型用法代碼示例。如果您正苦於以下問題:Java Converter類的具體用法?Java Converter怎麽用?Java Converter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Converter類屬於javax.faces.convert包,在下文中一共展示了Converter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDefaultColumns

import javax.faces.convert.Converter; //導入依賴的package包/類
@Override
protected Integer getDefaultColumns(
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean)
{
  Integer columnsInteger = null;

  Converter converter = getConverter(component, bean);

  // Ignoring the "default" converter code is intentional;  we'll just
  // fall through to _DEFAULT_COLUMNS here to save time
  if (converter instanceof ColorConverter)
  {
    int columns = ((ColorConverter) converter).getColumns(FacesContext.getCurrentInstance());
    columnsInteger = columns;
  }
  else
  {
    columnsInteger = _DEFAULT_COLUMNS;
  }

  return columnsInteger;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:SimpleInputColorRenderer.java

示例2: restoreState

import javax.faces.convert.Converter; //導入依賴的package包/類
@Override
public void restoreState(FacesContext context, Object state) {
	Object values[] = (Object[]) state;
	super.restoreState(context, values[0]);
       columnTitle = (String)values[1];
       columnName = (String)values[2];
	value = StateHolderUtil.restoreObjectState(context,getComponent(),values[3]);
       converter = (Converter)StateHolderUtil.restoreObjectState(context, getComponent(), values[4]);
       style = (String)values[5];
       styleClass = (String)values[6];
       href = (String)values[7];
       contentType = (String)values[8];
       headerStyle = (String)values[9];
       headerStyleClass = (String)values[10];
       linkTitle = (String)values[11];
       headerLinkTitle = (String)values[12];
}
 
開發者ID:OpenNTF,項目名稱:XPagesExtensionLibrary,代碼行數:18,代碼來源:ValueColumn.java

示例3: createDeployment

import javax.faces.convert.Converter; //導入依賴的package包/類
@Deployment
public static WebArchive createDeployment()
{
    MavenDependencyResolver resolver = DependencyResolvers.use( MavenDependencyResolver.class )
            .loadMetadataFromPom( "pom.xml" );

    return ShrinkWrap.create(WebArchive.class)
            .addClasses( HtmlSelectOneMenu.class, YAMLUtils.class, Converter.class, SettopInfo.class, DevRack.class)
            .addAsLibraries(resolver.artifact("org.yaml:snakeyaml:1.10").resolveAsFiles())
            .addAsLibraries(resolver.artifact("commons-lang:commons-lang:2.3").resolveAsFiles())
            .addAsLibraries(resolver.artifact("log4j:log4j:1.2.14").resolveAsFiles())
            .addAsLibraries(resolver.artifact("org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final").resolveAsFiles())
            .addAsLibraries(resolver.artifact("org.primefaces:primefaces:3.4.1").resolveAsFiles())
            .addAsLibraries(resolver.artifact("com.comcast.cats:ir-common:3.2.0.5").resolveAsFiles())
     /*     .addAsLibraries(resolver.artifact("org.jboss.spec.javax.faces:jboss-jsf-api_2.0_spec:1.0.0.Final").resolveAsFiles())*/
            .addPackage( SlotConnectionRepresenter.class.getPackage() )
            .addPackage( SettopSlotConfigServiceImpl.class.getPackage() )
            .addPackage( Slot.class.getPackage() )
            .addAsResource(new File("src/test/resources", "rackconfig.catsrack"))
            .addAsResource(new File("src/test/resources", "settops.catsrack"))
            .addAsResource(new File("src/test/resources", "settopTypes.catsrack"))
            .addPackage( SettopDesc.class.getPackage() )
            .addAsWebInfResource( new File("src/main/webapp/WEB-INF/beans.xml"))
            .addAsWebInfResource( new File("src/main/webapp/WEB-INF/faces-config.xml"))
            .setWebXML(new File("src/main/webapp/WEB-INF/web.xml"));
}
 
開發者ID:Comcast,項目名稱:cats,代碼行數:27,代碼來源:RackControllerTest.java

示例4: getDefaultColumns

import javax.faces.convert.Converter; //導入依賴的package包/類
@Override
protected Integer getDefaultColumns(
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean)
{
  Integer columnsInteger = null;

  Converter converter = getConverter(component, bean);

  // Ignoring the "default" converter code is intentional;  we'll just
  // fall through to _DEFAULT_COLUMNS here to save time
  if (converter instanceof
      org.apache.myfaces.trinidadinternal.convert.DateTimeConverter)
  {
    int columns = ((org.apache.myfaces.trinidadinternal.convert.DateTimeConverter)
            converter).getColumns();
    columnsInteger = (columns);
  }
  else
  {
    columnsInteger = _DEFAULT_COLUMNS;
  }

  return columnsInteger;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:27,代碼來源:SimpleInputDateRenderer.java

示例5: addOnSubmitConverterValidators

import javax.faces.convert.Converter; //導入依賴的package包/類
public static void addOnSubmitConverterValidators(
  UIComponent         component,
  Converter           converter,
  Iterator<Validator> validators,
  String              clientId,
  boolean             immediate,
  boolean             required,
  String              requiredMessageKey
  ) throws IOException
{
  CoreFormData fData = (CoreFormData)
    RenderingContext.getCurrentInstance().getFormData();

  fData.addOnSubmitConverterValidators(component,
                                       converter,
                                       validators,
                                       clientId,
                                       immediate,
                                       required,
                                       requiredMessageKey);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:FormRenderer.java

示例6: encodeElementContent

import javax.faces.convert.Converter; //導入依賴的package包/類
@Override
protected void encodeElementContent(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean,
  List<SelectItem> selectItems,
  int              selectedIndex,
  Converter        converter,
  boolean          valuePassThru
  ) throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  writer.startElement("select", component);
  renderId(context, component);
  renderAllAttributes(context, rc, component, bean, false);

  encodeSelectItems(context, rc, component, bean,
                    selectItems, selectedIndex, converter,
                    valuePassThru);

  writer.endElement("select");
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:SimpleSelectOneChoiceRenderer.java

示例7: getConvertedString

import javax.faces.convert.Converter; //導入依賴的package包/類
protected String getConvertedString(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean)
{
  Object value = getValue(component, bean);
  Converter converter = getConverter(component, bean);
  // If there's no explicitly set converter, and the value is non-null
  // and not a String, try to get a default converter
  if ((converter == null) &&
      (value != null) &&
      !(value instanceof String))
    converter = getDefaultConverter(context, component, bean);

  if (converter != null)
  {
    return converter.getAsString(context, component, value);
  }

  return toString(value);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:ValueRenderer.java

示例8: getItemValue

import javax.faces.convert.Converter; //導入依賴的package包/類
/**
 * Return the value to output for an item.
 */
static public Object getItemValue(
  FacesContext context,
  UIComponent  component,
  SelectItem   item,
  Converter    converter,
  boolean      valuePassThru,
  int          index)
{
  if (!valuePassThru)
  {
    return IntegerUtils.getString(index);
  }
  else
  {
    Object itemValue = item.getValue();
    if ((itemValue != null) && (converter != null))
    {
      itemValue = converter.getAsString(context,
                                        component,
                                        itemValue);
    }

    return itemValue;
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:29,代碼來源:SimpleSelectOneRenderer.java

示例9: getConvertedValue

import javax.faces.convert.Converter; //導入依賴的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;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:29,代碼來源:EditableValueRenderer.java

示例10: getDefaultConverter

import javax.faces.convert.Converter; //導入依賴的package包/類
/**
 * Override to return a Converter for the items in the value,
 * not the value itself.
 */
@Override
protected Converter getDefaultConverter(
  FacesContext context,
  UIComponent  copmonent,
  FacesBean    bean)
{
  ValueExpression expression = getValueExpression(copmonent, bean);
  if (expression == null)
    return null;

  Class<?> type = expression.getType(context.getELContext());
  if ((type == null) || type.isAssignableFrom(List.class))
    return null;

  if (type.isArray())
  {
    Class<?> itemClass = type.getComponentType();
    return ConverterUtils.createConverter(context, itemClass);
  }

  _throwUnsupportedModelType(context, type, null);
  return null;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:28,代碼來源:SimpleSelectManyRenderer.java

示例11: getValue

import javax.faces.convert.Converter; //導入依賴的package包/類
public Object getValue(UIXRenderingContext context)
{
  FacesBean bean = _component.getFacesBean();
  // Try to get an explicit Converter
  Converter converter = (Converter)
    bean.getProperty(UIXValue.CONVERTER_KEY);

  // OK, no explicit converter, look at the ValueExpression
  if (converter == null)
  {
    ValueExpression expression = bean.getValueExpression(UIXValue.VALUE_KEY);
    if (expression != null)
    {
      FacesContext fContext = (context == null) ? 
        FacesContext.getCurrentInstance() : context.getFacesContext();
      Class<?> type = expression.getType(fContext.getELContext());
      converter = ConverterUtils.createConverter(fContext, type);
    }
  }
  
  return converter;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:ConverterBoundValue.java

示例12: getConvertedValue

import javax.faces.convert.Converter; //導入依賴的package包/類
protected Object getConvertedValue(
  FacesContext    context,
  CoreOutputText  cot)
{
  Object value = cot.getValue();
  if (value == null)
    return null;

  Converter converter = cot.getConverter();
  if ((converter == null) && !(value instanceof String))
  {
    converter = getConverterByType(context, cot);
  }

  if (converter != null)
  {
    return converter.getAsString(context, cot, value);
  }

  return value;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:FastRenderer.java

示例13: getConvertedValue

import javax.faces.convert.Converter; //導入依賴的package包/類
protected Object getConvertedValue(
  FacesContext context,
  UIComponent  component,
  FacesBean    bean)
{
  Object value = getValue(component, bean);
  if (value == null)
    return null;

  Converter converter = getConverter(component, bean);
  if ((converter == null) && !(value instanceof String))
  {
    converter = getConverterByType(context, bean);
  }

  if (converter != null)
  {
    return converter.getAsString(context, component, value);
  }

  return value;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:FastRenderer2.java

示例14: _getNotInRangeMessage

import javax.faces.convert.Converter; //導入依賴的package包/類
private FacesMessage _getNotInRangeMessage(
  FacesContext context,
  UIComponent component,
  Object value,
  Object min,
  Object max)
{ 
  Converter converter = _getConverter(context, component);

  Object cValue = _getConvertedValue(context, component, converter, value);
  Object cMin   = _getConvertedValue(context, component, converter, min);
  Object cMax   = _getConvertedValue(context, component, converter, max);

  Object msg   = _getRawNotInRangeMessageDetail();
  Object label = ValidatorUtils.getComponentLabel(component);

  Object[] params = {label, cValue, cMin, cMax};

  return MessageFactory.getMessage(context, NOT_IN_RANGE_MESSAGE_ID,
                                    msg, params, component);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:DateTimeRangeValidator.java

示例15: _getMaximumMessage

import javax.faces.convert.Converter; //導入依賴的package包/類
private FacesMessage _getMaximumMessage(
  FacesContext context,
  UIComponent component,
  Object value,
  Object max)
{
  Converter converter = _getConverter(context, component);

  Object cValue = _getConvertedValue(context, component, converter, value);
  Object cMax   = _getConvertedValue(context, component, converter, max);

  Object msg   = _getRawMaximumMessageDetail();
  Object label = ValidatorUtils.getComponentLabel(component);

  Object[] params = {label, cValue, cMax};

  return MessageFactory.getMessage(context,
                                   MAXIMUM_MESSAGE_ID,
                                   msg,
                                   params,
                                   component);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:DateTimeRangeValidator.java


注:本文中的javax.faces.convert.Converter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。