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


Java SelectItem.isDisabled方法代碼示例

本文整理匯總了Java中javax.faces.model.SelectItem.isDisabled方法的典型用法代碼示例。如果您正苦於以下問題:Java SelectItem.isDisabled方法的具體用法?Java SelectItem.isDisabled怎麽用?Java SelectItem.isDisabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.model.SelectItem的用法示例。


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

示例1: _convertSelectItemListToIndices

import javax.faces.model.SelectItem; //導入方法依賴的package包/類
/**
 * Rips through the list of SelectItems, and sets all item's
 * values to their index
 */
static private void _convertSelectItemListToIndices(
  List<SelectItem>     itemsToConvert)
{
  int length = itemsToConvert.size();
  // loop through each item to convert.
  for (int j=0; j < length; j++)
  {
    SelectItem oldSelectItem = itemsToConvert.get(j);
    // We have to create a new item - the old ones are not
    // necessarily ours, so we can't just mutate 'em
    SelectItem newSelectItem = new SelectItem(j,
                                             oldSelectItem.getLabel(),
                                             oldSelectItem.getDescription(),
                                             oldSelectItem.isDisabled());
    itemsToConvert.set(j, newSelectItem);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:22,代碼來源:SelectManyShuttleRenderer.java

示例2: encodeOption

import javax.faces.model.SelectItem; //導入方法依賴的package包/類
/**
 * @todo Move to utility class?
 */
static public boolean encodeOption(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  SelectItem       item,
  Converter        converter,
  boolean          valuePassThru,
  int              index,
  boolean          isSelected
  ) throws IOException
{
  if (item == null)
    return false;

  if (item.isDisabled())
  {
    if (!Boolean.TRUE.equals(rc.getAgent().getCapabilities().get(
                        TrinidadAgent.CAP_SUPPORTS_DISABLED_OPTIONS)))
      return false;
  }

  Object itemValue = getItemValue(context,
                                  component,
                                  item,
                                  converter,
                                  valuePassThru,
                                  index);

  ResponseWriter writer = context.getResponseWriter();

  writer.startElement("option", null);

  if (item.isDisabled())
    writer.writeAttribute("disabled", Boolean.TRUE, null);

  // Never write out null, because that will result in the label
  // getting submitted, instead of null.
  if (itemValue == null)
    itemValue="";
  writer.writeAttribute("value", itemValue, null);

  if (isSelected)
    writer.writeAttribute("selected", Boolean.TRUE, null);

  // For reasons that aren't especially clear to me, we're getting
  // passed the empty string for our title.
  String description = item.getDescription();
  if ((description != null) && !"".equals(description))
    writer.writeAttribute("title", description, null);

  writer.writeText(item.getLabel(), null);

  writer.endElement("option");

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

示例3: renderSelectItem

import javax.faces.model.SelectItem; //導入方法依賴的package包/類
/**
 * Render a single select item.
 * @param renderedOne true if an item has already been rendered
 * @return false if nothing was rendered, true otherwise
 */
protected boolean renderSelectItem(
  UIXRenderingContext context,
  UINode           node,
  UIComponent      component,
  SelectItem       item,
  String           value,
  boolean          isSelected,
  boolean          renderedOne,
  int              index) throws IOException
{
  if (item == null)
    return false;
  boolean agentSupportsDisabledOptions = Boolean.TRUE
      .equals(getAgentCapability(context,
          TrinidadAgent.CAP_SUPPORTS_DISABLED_OPTIONS));
  boolean isParentDisabled = Boolean.TRUE.equals(component.getAttributes()
      .get(DISABLED_ATTR.getAttributeName()));  
  if (!isParentDisabled && item.isDisabled()
      && (!(agentSupportsDisabledOptions)))
    return false;

  //
  FacesContext fContext = context.getFacesContext();
  ResponseWriter out = fContext.getResponseWriter();

  if (!renderAsElement(context, node))
  {
    if (isSelected)
    {
      if (renderedOne)
      {
        out.startElement("br", null);
        out.endElement("br");
      }

      out.writeText(item.getLabel(), null);
      return true;
    }
  }
  else
  {
    out.startElement("option", null);

    if (item.isDisabled())
      out.writeAttribute("disabled", Boolean.TRUE, null);

    out.writeAttribute("value", value, null);
    if (isSelected)
      out.writeAttribute("selected", Boolean.TRUE, null);

    out.writeAttribute("title", item.getDescription(), null);

    out.writeText(item.getLabel(), null);

    out.endElement("option");
  }

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


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