Java Code Examples for javax.faces.model.SelectItem

The following are top voted examples for showing how to use javax.faces.model.SelectItem. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm-app   File: ManageServiceInstanceCtrl.java   View source code 8 votes vote down vote up
private List<ServiceInstanceRow> initServiceInstanceRows()
        throws ServiceInstanceException {
    List<ServiceInstance> serviceInstances = getServiceInstanceService()
            .getInstancesForController(getControllerId());
    List<ServiceInstanceRow> result = new ArrayList<>();
    if (serviceInstances == null) {
        return result;
    }
    for (ServiceInstance serviceInstance : serviceInstances) {
        List<SelectItem> selectableOperations = initSelectableOperaions(
                serviceInstance);
        ServiceInstanceRow row = new ServiceInstanceRow(serviceInstance,
                selectableOperations);
        result.add(row);
    }
    return result;

}
 
Example 2
Project: myfaces-trinidad   File: ChoiceRenderer.java   View source code 7 votes vote down vote up
private boolean _isNothingSelected(
  UIComponent      component,
  List<SelectItem> selectItems)
{
  // Assume the component is a value holder
  Object value = ((ValueHolder) component).getValue();
  if (value == null)
    return true;
  // now check if none of the items' values match the value.
  int size = selectItems.size();
  for (int i=0; i < size; i++)
  {
    SelectItem item = selectItems.get(i);
    if (value.equals(item.getValue()))
      return false;
  }
  return true;
}
 
Example 3
Project: ctsms   File: VisitScheduleBean.java   View source code 6 votes vote down vote up
private void initSets() {
	collidingProbandStatusEntryModelCache.clear();
	visitScheduleItemModel.setTrialId(in.getTrialId());
	visitScheduleItemModel.updateRowCount();
	visits = WebUtil.getVisits(in.getTrialId());
	probandGroups = WebUtil.getProbandGroups(in.getTrialId());
	filterProbandGroups = new ArrayList<SelectItem>(probandGroups);
	filterProbandGroups.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	filterVisits = new ArrayList<SelectItem>(visits);
	filterVisits.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	matrix.initPages();
	// loadMatrix();
	trial = WebUtil.getTrial(this.in.getTrialId());
	if (WebUtil.isTrialLocked(trial)) {
		Messages.addLocalizedMessage(FacesMessage.SEVERITY_WARN, MessageCodes.TRIAL_LOCKED);
	}
}
 
Example 4
Project: myfaces-trinidad   File: SimpleSelectOneRenderer.java   View source code 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example 5
Project: ctsms   File: ECRFSectionProgressConverter.java   View source code 6 votes vote down vote up
@Override
public Object getAsObject(FacesContext facesContext, UIComponent component, String submittedValue) {
	// if (submittedValue.trim().equals(CommonUtil.NO_SELECTION_VALUE)) {
	// return null;
	// } else {
	// http://stackoverflow.com/questions/9147119/avoid-extra-db-reads-in-the-getasobject-method-of-converter-class-by-caching-dat
	Iterator<SelectItem> it = new SelectItemsIterator(facesContext, component);
	while (it.hasNext()) {
		Object value = it.next().getValue();
		if (value instanceof ECRFSectionProgressVO) {
			if (submittedValue.equals(((ECRFSectionProgressVO) value).getSection())) {
				return value;
			}
		} else if (value instanceof String) {
			if (submittedValue.equals(value)) {
				ECRFSectionProgressVO progress = new EcrfSectionProgressItemValue();
				progress.setSection((String) value);
				return progress;
			}
		}
	}
	// System.out.println("section progress for " + submittedValue + " not found");
	return null;
	// }
}
 
Example 6
Project: myfaces-trinidad   File: SimpleSelectOneRenderer.java   View source code 6 votes vote down vote up
private static int calcItems(
  SelectItem item)
{
  if(item instanceof SelectItemGroup)
  {
    int count = 0;
    SelectItem[] items;
    items = ((SelectItemGroup)item).getSelectItems();

    for(int i = 0; i < items.length; i++)
    {
      count += calcItems( items[i] );
    }

    return count;
  }

  return 1;
}
 
Example 7
Project: oscm   File: GotoMarketplaceBeanTest.java   View source code 6 votes vote down vote up
/**
 * The user has only the SERVICE_MANAGER role, therefore only marketplaces
 * with publishing rights must be loaded.
 */
@Test
public void loadMarketplaces_NoMarketplaceOwner() {
    // given two marketplaces
    doReturn(Boolean.FALSE).when(marketplaceGotoBean)
            .isLoggedInAndMarketplaceOwner();
    given(mpServiceMock.getMarketplacesForOrganization()).willReturn(
            marketplace(1L, "publishedMp"));
    given(mpServiceMock.getMarketplacesOwned()).willReturn(
            marketplace(2L, "ownedMp"));

    // when
    List<SelectItem> marketplaces = marketplaceGotoBean.getMarketplaces();

    // then only one is loaded
    assertEquals(1, marketplaces.size());
    assertEquals("publishedMp", marketplaces.get(0).getValue());
}
 
Example 8
Project: Multicentro_Mascotas   File: SelectOneMenuView.java   View source code 6 votes vote down vote up
@PostConstruct
/*     */   public void init()
/*     */   {
/*  48 */     SelectItemGroup g1 = new SelectItemGroup("German Cars");
/*  49 */     g1.setSelectItems(new SelectItem[] { new SelectItem("BMW", "BMW"), new SelectItem("Mercedes", "Mercedes"), new SelectItem("Volkswagen", "Volkswagen") });
/*     */ 
/*  51 */     SelectItemGroup g2 = new SelectItemGroup("American Cars");
/*  52 */     g2.setSelectItems(new SelectItem[] { new SelectItem("Chrysler", "Chrysler"), new SelectItem("GM", "GM"), new SelectItem("Ford", "Ford") });
/*     */ 
/*  54 */     this.cars = new ArrayList();
/*  55 */     this.cars.add(g1);
/*  56 */     this.cars.add(g2);
/*     */ 
/*  59 */     this.cities = new HashMap();
/*  60 */     this.cities.put("New York", "New York");
/*  61 */     this.cities.put("London", "London");
/*  62 */     this.cities.put("Paris", "Paris");
/*  63 */     this.cities.put("Barcelona", "Barcelona");
/*  64 */     this.cities.put("Istanbul", "Istanbul");
/*  65 */     this.cities.put("Berlin", "Berlin");
/*     */ 
/*  68 */     this.themes = this.service.getThemes();
/*     */   }
 
Example 9
Project: myfaces-trinidad   File: SelectRangeChoiceBarRenderer.java   View source code 6 votes vote down vote up
private SelectItem _createNavigationItem(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  long             blockStart,
  int              blockSize,
  long             maxValue,
  String           text,
  UIComponent      rangeLabel
  )
{
  // if text isn't null, it is More or Previous.
  if (text == null)
    text = _getRangeString(context,
                           rc,
                           component,
                           blockStart,
                           blockSize,
                           maxValue,
                           rangeLabel);

  return new SelectItem(IntegerUtils.getString(blockStart),
                        text);
}
 
Example 10
Project: programacion4-final   File: ControllerDocument.java   View source code 6 votes vote down vote up
public void selectTypeUser(){
    selectTypeDoc = new SelectItem[alltd.size()];
    
    for(int i = 0; i < alltd.size();i++){
        TypeDoc td1 = alltd.get(i);
        selectTypeDoc[i] = new SelectItem(td1.getTypedocId(),td1.getName());
    }
}
 
Example 11
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterEventImportances() {
	if (filterEventImportances == null) {
		filterEventImportances = WebUtil.getEventImportances();
		filterEventImportances.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterEventImportances;
}
 
Example 12
Project: oscm-app   File: ManageServiceInstanceCtrl.java   View source code 5 votes vote down vote up
private List<SelectItem> initSelectableOperaions(
        ServiceInstance serviceInstance) {
    List<SelectItem> selectableOperations = new ArrayList<>();
    for (InstanceOperation operation : getServiceInstanceService()
            .listOperationsForInstance(serviceInstance)) {
        if (filterOperation(operation, serviceInstance)) {
            selectableOperations.add(new SelectItem(operation));
        }
    }
    return selectableOperations;
}
 
Example 13
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterVariablePeriods() {
	if (filterVariablePeriods == null) {
		filterVariablePeriods = WebUtil.getVariablePeriods();
		filterVariablePeriods.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterVariablePeriods;
}
 
Example 14
Project: ctsms   File: ProbandMoneyTransferSummaryLazyModelBase.java   View source code 5 votes vote down vote up
private void initSets() {
	costTypesTruncated = null;
	isCostTypeColumnsTruncated = false;
	truncatedCostTypes = null;
	if (costTypes == null) {
		costTypes = new ArrayList<String>();
		costTypesTruncated = costTypes;
		truncatedCostTypes = new ArrayList<SelectItem>();
		truncatedCostTypeIndex = null;
	} else {
		Long limit = Settings.getLongNullable(SettingCodes.MAX_COST_TYPES_COLUMNS, Bundle.SETTINGS, DefaultSettings.MAX_COST_TYPES_COLUMNS);
		truncatedCostTypes = new ArrayList<SelectItem>();
		if (limit != null && costTypes.size() > limit) {
			costTypesTruncated = new ArrayList<String>();
			Iterator<String> it = costTypes.iterator();
			Long index = 0l;
			while (it.hasNext()) {
				if ((costTypesTruncated.size() + 1) < limit) {
					costTypesTruncated.add(it.next());
				} else {
					if (truncatedCostTypeIndex == null) {
						truncatedCostTypeIndex = index;
					}
					truncatedCostTypes.add(new SelectItem(index.toString(), it.next()));
				}
				index++;
			}
			isCostTypeColumnsTruncated = true;
		} else {
			costTypesTruncated = costTypes;
			truncatedCostTypeIndex = null;
		}
	}
}
 
Example 15
Project: oscm   File: CustomizeLandingpageCtrlTest.java   View source code 5 votes vote down vote up
private void setPublicLandingpageSelected() {
    model.setLandingpageType(LandingpageType.PUBLIC.name());
    model.setSelectedMarketplace(PUBLIC_MARKETPLACE_ID);
    model.setLandingpageConfig(new POPublicLandingpageConfig());
    model.setAvailableServices(new ArrayList<POService>());
    model.setFillinItems(new ArrayList<SelectItem>());
}
 
Example 16
Project: oscm   File: MySubscriptionsCtrl.java   View source code 5 votes vote down vote up
List<SelectItem> convert(List<String> list) {
    List<SelectItem> result = new LinkedList<>();
    if (list != null) {
        for (String s : list) {
            result.add(new SelectItem(s, s));
        }
    }
    return result;
}
 
Example 17
Project: myfaces-trinidad   File: SimpleSelectManyRenderer.java   View source code 5 votes vote down vote up
protected List<SelectItem> getSelectItems(
  UIComponent component,
  Converter   converter,
  boolean     filteredItems)
{
  return SelectItemSupport.getSelectItems(component, converter, filteredItems);
}
 
Example 18
Project: ctsms   File: Paginator.java   View source code 5 votes vote down vote up
private void updatePageSizes() {
	ArrayList<String> sizeStrings = getPageSizeStrings();
	pageSizes.clear();
	Iterator<String> it = sizeStrings.iterator();
	while (it.hasNext()) {
		String sizeString = it.next();
		pageSizes.add(new SelectItem(sizeString, sizeString));
	}
}
 
Example 19
Project: oscm   File: LdapConfigurationCtrl.java   View source code 5 votes vote down vote up
/**
 * Initializes the list of LDAP managed organizations.
 */
void initOrgData() {
    Set<POLdapOrganization> ldapManagedOrganizations = getUserManagementService()
            .getLdapManagedOrganizations();
    model.getOrganizations().clear();
    for (POLdapOrganization poLdapOrganization : ldapManagedOrganizations) {
        String nameToDisplay = poLdapOrganization.getName() == null ? poLdapOrganization
                .getIdentifier() : String.format("%s (%s)",
                poLdapOrganization.getName(),
                poLdapOrganization.getIdentifier());
        model.getOrganizations().add(
                new SelectItem(poLdapOrganization.getIdentifier(),
                        nameToDisplay));
    }
}
 
Example 20
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterTrialTypes() {
	if (filterTrialTypes == null) {
		filterTrialTypes = WebUtil.getAllTrialTypes();
		filterTrialTypes.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterTrialTypes;
}
 
Example 21
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterPrivacyConsentStatusTypes() {
	if (filterPrivacyConsentStatusTypes == null) {
		filterPrivacyConsentStatusTypes = WebUtil.getAllPrivacyConsentStatusTypes();
		filterPrivacyConsentStatusTypes.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterPrivacyConsentStatusTypes;
}
 
Example 22
Project: oscm   File: ManageOperatorRevenueShareCtrl.java   View source code 5 votes vote down vote up
void initTemplateServiceSelector() {
    List<SelectItem> uiTemplateServices = new ArrayList<SelectItem>();
    Response response = sl.findService(ServiceSelector.class)
            .getTemplateServices();
    List<POService> templates = response.getResultList(POService.class);
    for (POService templateService : templates) {
        uiTemplateServices.add(new SelectItem(Long.valueOf(templateService
                .getKey()), templateService.getServiceId() + "("
                + templateService.getVendorOrganizationId() + ")"));
    }
    model.setTemplates(uiTemplateServices);
}
 
Example 23
Project: Multicentro_Mascotas   File: FormsView.java   View source code 5 votes vote down vote up
@PostConstruct
/*    */   public void init()
/*    */   {
/* 40 */     SelectItemGroup g1 = new SelectItemGroup("German Cars");
/* 41 */     g1.setSelectItems(new SelectItem[] { new SelectItem("BMW", "BMW"), new SelectItem("Mercedes", "Mercedes"), new SelectItem("Volkswagen", "Volkswagen") });
/*    */ 
/* 43 */     SelectItemGroup g2 = new SelectItemGroup("American Cars");
/* 44 */     g2.setSelectItems(new SelectItem[] { new SelectItem("Chrysler", "Chrysler"), new SelectItem("GM", "GM"), new SelectItem("Ford", "Ford") });
/*    */ 
/* 46 */     this.carsGroup = new ArrayList();
/* 47 */     this.carsGroup.add(g1);
/* 48 */     this.carsGroup.add(g2);
/*    */   }
 
Example 24
Project: myfaces-trinidad   File: SimpleSelectManyRenderer.java   View source code 5 votes vote down vote up
private List<SelectItem> flatItemList(List<SelectItem> selectItems)
{
   List<SelectItem> result = new ArrayList<SelectItem>();
   for(SelectItem item : selectItems)
   {
      List<SelectItem> subresult = collectItems( item );

      for(SelectItem subItem : subresult)
      {
         result.add( subItem );
      }
   }

   return result;
}
 
Example 25
Project: oscm   File: UpdateMarketplaceBeanTest.java   View source code 5 votes vote down vote up
@Test
public void getSelectableMarketplaces_Operator() {
    doReturn(Boolean.TRUE).when(umpb).isLoggedInAndPlatformOperator();
    List<SelectItem> list = umpb.getSelectableMarketplaces();
    verify(msmock, times(1)).getMarketplacesForOperator();
    assertEquals(2, list.size());
}
 
Example 26
Project: oscm   File: ExportBillingDataCtrl.java   View source code 5 votes vote down vote up
/**
 * selectable options switching different dialog types only for controlling
 * view options.
 */
void initializeBillingDataTypeOptions() {
    List<BillingDataType> billingDataTypes = null;
    if (model.isSupplierOrReseller()) {
        billingDataTypes = Arrays.asList(BillingDataType.values());
    } else {
        billingDataTypes = Arrays.asList(BillingDataType.RevenueShare);
    }
    List<SelectItem> billingDataTypeOptions = new SelectItemBuilder(ui)
            .buildSelectItems(billingDataTypes, "BillingDataType");
    model.setBillingDataTypeOptions(billingDataTypeOptions);
}
 
Example 27
Project: ctsms   File: SelectItemsIterator.java   View source code 5 votes vote down vote up
public SelectItem next() {
	if (index >= count) {
		throw new NoSuchElementException();
	}
	Object item = Array.get(array, index++);
	if (item instanceof SelectItem) {
		return (SelectItem) item;
	} else {
		return getSelectItemFor(ctx, item);
	}
}
 
Example 28
Project: oscm   File: TrackingCodeCtrl.java   View source code 5 votes vote down vote up
private List<SelectItem> initMarketplaceSelector(List<POMarketplace> mpls) {
    List<SelectItem> uiMarketplaces = new ArrayList<SelectItem>();
    for (POMarketplace mp : mpls) {
        uiMarketplaces.add(new SelectItem(mp.getMarketplaceId(), mp
                .getDisplayName()));
    }
    return uiMarketplaces;
}
 
Example 29
Project: ctsms   File: PortalBean.java   View source code 5 votes vote down vote up
public ArrayList<SelectItem> getFilterNotificationTypes() {
	if (filterNotificationTypes == null) {
		filterNotificationTypes = WebUtil.getAllNotificationTypes();
		filterNotificationTypes.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterNotificationTypes;
}
 
Example 30
Project: oscm   File: UpdateMarketplaceBeanTest.java   View source code 5 votes vote down vote up
@Test
public void getSelectableMarketplaces() {
    List<SelectItem> list = umpb.getSelectableMarketplaces();
    verify(msmock, times(1)).getMarketplacesOwned();

    assertEquals(2, list.size());
    SelectItem item = list.get(0);
    assertEquals(vMp1.getName() + " (" + vMp1.getMarketplaceId() + ")",
            item.getLabel());
    assertEquals(vMp1.getMarketplaceId(), item.getValue());
}
 
Example 31
Project: oscm   File: TriggerDefinitionBean.java   View source code 5 votes vote down vote up
public SelectItem[] getTriggerTypeValues() {
    final SelectItem[] items = new SelectItem[this.getTriggerTypes().size()];
    int i = 0;
    for (final TriggerType tType : this.getTriggerTypes()) {
        items[i++] = new SelectItem(tType, JSFUtils.getText("TriggerType." + tType + ".enum", null));
    }
    return items;
}
 
Example 32
Project: oscm   File: OperatorOrgBean.java   View source code 5 votes vote down vote up
private String getSelectedTenantId() {
    for (SelectItem selectedTenantItem : getSelectableTenants()) {
        if (selectedTenantItem.getValue().toString().equals(selectedTenant)) {
            return selectedTenantItem.getLabel();
        }
    }
    return "";
}
 
Example 33
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterInverseBooleans() {
	if (filterInverseBooleans == null) {
		filterInverseBooleans = WebUtil.getBooleans(true, false);
		filterInverseBooleans.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterInverseBooleans;
}
 
Example 34
Project: ctsms   File: SelectItemsIterator.java   View source code 5 votes vote down vote up
/**
 * <p>Return the next element in the iteration.</p>
 *
 * @throws NoSuchElementException if there are no more elements
 */
@SuppressWarnings({ "unchecked" })
public SelectItem next() {
	if (!hasNext()) {
		throw new NoSuchElementException();
	}
	if (items != null) {
		return (items.next());
	}
	return next();
}
 
Example 35
Project: myfaces-trinidad   File: SimpleSelectOneRenderer.java   View source code 5 votes vote down vote up
protected List<SelectItem> getSelectItems(
  UIComponent component,
  Converter   converter,
  boolean     filteredItems)
{
  return SelectItemSupport.getSelectItems(component, converter, filteredItems);
}
 
Example 36
Project: oscm   File: UpdateMarketplaceBean.java   View source code 5 votes vote down vote up
/**
 * Updates the label of the {@link SelectItem} matching the passed
 * {@link VOMarketplace}.
 *
 * @param mp
 *            the {@link VOMarketplace} to get the new label from
 * @param list
 *            the list of {@link SelectItem} to update
 */
void updateSelectionList(VOMarketplace mp, List<SelectItem> list) {
    if (list == null) {
        return;
    }
    for (SelectItem si : list) {
        if (mp.getMarketplaceId().equals(si.getValue())) {
            si.setLabel(getLabel(mp));
            break;
        }
    }
}
 
Example 37
Project: ctsms   File: SelectItemsIterator.java   View source code 5 votes vote down vote up
public SelectItem next() {
	Map.Entry entry = (Map.Entry) iterator.next();
	Object key = entry.getKey();
	Object value = entry.getValue();
	item.setLabel(((key != null) ? key.toString() : value.toString()));
	item.setValue(((value != null) ? value : ""));
	return item;
}
 
Example 38
Project: TreasureHunting   File: JsfUtil.java   View source code 5 votes vote down vote up
public static SelectItem[] getSelectItems(List<?> entities, boolean selectOne) {
    int size = selectOne ? entities.size() + 1 : entities.size();
    SelectItem[] items = new SelectItem[size];
    int i = 0;
    if (selectOne) {
        items[0] = new SelectItem("", "---");
        i++;
    }
    for (Object x : entities) {
        items[i++] = new SelectItem(x, x.toString());
    }
    return items;
}
 
Example 39
Project: ctsms   File: SessionScopeBean.java   View source code 5 votes vote down vote up
public synchronized ArrayList<SelectItem> getFilterTimelineEventTypes() {
	if (filterTimelineEventTypes == null) {
		filterTimelineEventTypes = WebUtil.getAllTimelineEventTypes();
		filterTimelineEventTypes.add(0, new SelectItem(CommonUtil.NO_SELECTION_VALUE, ""));
	}
	return filterTimelineEventTypes;
}
 
Example 40
Project: oscm   File: DeleteCustomerPriceModelCtrlTest.java   View source code 5 votes vote down vote up
@Test
public void getOrgName_NotFound() {
    model.setCustomers(Arrays.asList(new SelectItem("1", "A"),
            new SelectItem("2", "B")));
    model.setSelectedOrgId("3");

    String orgName = ctrl.getOrgName();

    assertEquals("3", orgName);
}