Java Code Examples for javax.faces.model.SelectItem#setValue()

The following examples show how to use javax.faces.model.SelectItem#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SectionBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get a numerical sequence for all parts.
 * Derived property.
 * @return String[] in format "1", "2", "3"... up to the number of parts
 */
public List getSectionNumberList()
{
  List list = new ArrayList();

  if (assessmentSectionIdents==null) return list;

  for (int i = 0; i < assessmentSectionIdents.toArray().length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel("" + i);
    selection.setValue("" + i);
    list.add(selection);
  }

  return list;
}
 
Example 2
Source File: CoordinatorEvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getExecutionPeriodsLabels() {
    if (this.executionPeriodsLabels == null) {
        this.executionPeriodsLabels = new ArrayList();

        final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
        final ComparatorChain comparatorChain = new ComparatorChain();
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
        Collections.sort(infoExecutionPeriods, comparatorChain);
        for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            final SelectItem selectItem = new SelectItem();
            selectItem.setValue(infoExecutionPeriod.getExternalId());
            selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear());
            this.executionPeriodsLabels.add(selectItem);
        }
    }
    return this.executionPeriodsLabels;
}
 
Example 3
Source File: DisplayEvaluationsForStudentToEnrol.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getExecutionPeriodsLabels() {
    if (this.executionPeriodsLabels == null) {
        this.executionPeriodsLabels = new ArrayList();

        final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
        final ComparatorChain comparatorChain = new ComparatorChain();
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
        Collections.sort(infoExecutionPeriods, comparatorChain);
        for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            final SelectItem selectItem = new SelectItem();
            selectItem.setValue(infoExecutionPeriod.getExternalId());
            selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear());
            this.executionPeriodsLabels.add(selectItem);
        }
    }
    return this.executionPeriodsLabels;
}
 
Example 4
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List getSelectRelativeWidthList() {
 List<SelectItem> list = new ArrayList();
 ResourceLoader rb = new ResourceLoader(
"org.sakaiproject.tool.assessment.bundle.AuthorMessages");
 
 final String[] widthLists = {
	  rb.getString("matrix_width_list_default"),
	  rb.getString("matrix_width_list_1"),
	  rb.getString("matrix_width_list_2"),
	  rb.getString("matrix_width_list_3"),
	  rb.getString("matrix_width_list_4"),
	  rb.getString("matrix_width_list_5"),
	  rb.getString("matrix_width_list_6"),
	  rb.getString("matrix_width_list_7"),
	  rb.getString("matrix_width_list_8"),
	  rb.getString("matrix_width_list_9")};
 
 for (int i=0; i<widthLists.length;i++)
 {
  SelectItem selectItem = new SelectItem();
  selectItem.setLabel(widthLists[i]);
  selectItem.setValue(Integer.toString(i));
  list.add(selectItem);
 }
 return list;
}
 
Example 5
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getTrueFalseAnswerSelectList() {
  List list = new ArrayList();

  String trueprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","true_msg");
  String falseprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","false_msg");
  String[] answerValues = {"true", "false"};  // not to be displayed in the UI
  String[] answerLabelText= {trueprop, falseprop};
  currentItem.setAnswers(answerValues);
  currentItem.setAnswerLabels(answerLabelText);

  for (int i = 0; i < answerValues.length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel(answerLabelText[i]);
    selection.setValue(answerValues[i]);
    list.add(selection);
  }

  return list;
}
 
Example 6
Source File: AuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getSectionSelectList()
{
  List list = new ArrayList();

  if (sections == null) return list;

  for (int i = 0; i < sections.size(); i++) {
    SelectItem selection = new SelectItem();
    SectionBean sBean = (SectionBean) sections.get(i);
    selection.setLabel(sBean.getSectionTitle());
    selection.setValue(sBean.getSectionIdent());
    list.add(selection);
  }

  return list;
}
 
Example 7
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List getSelectRelativeWidthList() {
 List<SelectItem> list = new ArrayList();
 ResourceLoader rb = new ResourceLoader(
"org.sakaiproject.tool.assessment.bundle.AuthorMessages");
 
 final String[] widthLists = {
	  rb.getString("matrix_width_list_default"),
	  rb.getString("matrix_width_list_1"),
	  rb.getString("matrix_width_list_2"),
	  rb.getString("matrix_width_list_3"),
	  rb.getString("matrix_width_list_4"),
	  rb.getString("matrix_width_list_5"),
	  rb.getString("matrix_width_list_6"),
	  rb.getString("matrix_width_list_7"),
	  rb.getString("matrix_width_list_8"),
	  rb.getString("matrix_width_list_9")};
 
 for (int i=0; i<widthLists.length;i++)
 {
  SelectItem selectItem = new SelectItem();
  selectItem.setLabel(widthLists[i]);
  selectItem.setValue(Integer.toString(i));
  list.add(selectItem);
 }
 return list;
}
 
Example 8
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getTrueFalseAnswerSelectList() {
  List list = new ArrayList();

  String trueprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","true_msg");
  String falseprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","false_msg");
  String[] answerValues = {"true", "false"};  // not to be displayed in the UI
  String[] answerLabelText= {trueprop, falseprop};
  currentItem.setAnswers(answerValues);
  currentItem.setAnswerLabels(answerLabelText);

  for (int i = 0; i < answerValues.length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel(answerLabelText[i]);
    selection.setValue(answerValues[i]);
    list.add(selection);
  }

  return list;
}
 
Example 9
Source File: AuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getSectionSelectList()
{
  List list = new ArrayList();

  if (sections == null) return list;

  for (int i = 0; i < sections.size(); i++) {
    SelectItem selection = new SelectItem();
    SectionBean sBean = (SectionBean) sections.get(i);
    selection.setLabel(sBean.getSectionTitle());
    selection.setValue(sBean.getSectionIdent());
    list.add(selection);
  }

  return list;
}
 
Example 10
Source File: SectionBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get a numerical sequence for all parts.
 * Derived property.
 * @return String[] in format "1", "2", "3"... up to the number of parts
 */
public List getSectionNumberList()
{
  List list = new ArrayList();

  if (assessmentSectionIdents==null) return list;

  for (int i = 0; i < assessmentSectionIdents.toArray().length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel("" + i);
    selection.setValue("" + i);
    list.add(selection);
  }

  return list;
}
 
Example 11
Source File: ApplicationBean.java    From development with Apache License 2.0 5 votes vote down vote up
public List<SelectItem> getAvailableLanguageItems() {
    List<SelectItem> availableLanguageItems = new ArrayList<SelectItem>();
    for (String isoCode : getActiveLocales()) {
        SelectItem selectItem = new SelectItem();
        Locale languageLocale = new Locale(isoCode);
        String translatedLocale = languageLocale.getDisplayLanguage(ui
                .getViewLocale());
        selectItem.setLabel(translatedLocale);
        selectItem.setValue(isoCode);
        availableLanguageItems.add(selectItem);
    }
    return availableLanguageItems;
}
 
Example 12
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public List<SelectItem> getAuthorTypeList()
{

  List<SelectItem> list = new ArrayList<SelectItem>();
  // cannot disable only one radio button in a list, so am generating the list again

  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");

  SelectItem selection = new SelectItem();
  selection.setLabel(rb.getString("type_onebyone"));
  selection.setValue("1");
  list.add(selection);
  
  SelectItem selection1 = new SelectItem();
  boolean disabled = false;
  String label = rb.getString("random_draw_from_que");
  
  if (hideRandom)
  {
      label += " " + rb.getString("random_draw_from_que_edit_disabled");
      disabled = true;
  }
  else if (getPoolsAvailable().isEmpty())
  {
      label += " " + rb.getString("randow_draw_from_que_no_pools_available");
      disabled = true;
  }
  
  selection1.setDisabled(disabled);
  selection1.setLabel(label);
  selection1.setValue("2");
  list.add(selection1);

  return list;
}
 
Example 13
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* Get a numerical sequence for all questions.
* Derived property.
* @return String[] in format "1", "2", "3"... up to the number of questions
*/

 public List getItemNumberList(){
   List list = new ArrayList();

   for (int i = 0; i < items.toArray().length; i++) {
     SelectItem selection = new SelectItem();
     selection.setLabel("" + i);
     selection.setValue("" + i);
     list.add(selection);
   }

   return list;
 }
 
Example 14
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* Get a numerical sequence for all questions.
* Derived property.
* @return String[] in format "1", "2", "3"... up to the number of questions
*/

 public List getItemNumberList(){
   List list = new ArrayList();

   for (int i = 0; i < items.toArray().length; i++) {
     SelectItem selection = new SelectItem();
     selection.setLabel("" + i);
     selection.setValue("" + i);
     list.add(selection);
   }

   return list;
 }
 
Example 15
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public List<SelectItem> getAuthorTypeList()
{

  List<SelectItem> list = new ArrayList<SelectItem>();
  // cannot disable only one radio button in a list, so am generating the list again

  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");

  SelectItem selection = new SelectItem();
  selection.setLabel(rb.getString("type_onebyone"));
  selection.setValue("1");
  list.add(selection);
  
  SelectItem selection1 = new SelectItem();
  boolean disabled = false;
  String label = rb.getString("random_draw_from_que");
  
  if (hideRandom)
  {
      label += " " + rb.getString("random_draw_from_que_edit_disabled");
      disabled = true;
  }
  else if (getPoolsAvailable().isEmpty())
  {
      label += " " + rb.getString("randow_draw_from_que_no_pools_available");
      disabled = true;
  }
  
  selection1.setDisabled(disabled);
  selection1.setLabel(label);
  selection1.setValue("2");
  list.add(selection1);

  return list;
}
 
Example 16
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public List getSectionSelectList() {
  List list = new ArrayList();
  
  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
  AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
  List<SectionContentsBean> sectionSet = assessbean.getSections();
  Iterator<SectionContentsBean> iter = sectionSet.iterator();
  int i =0;
  while (iter.hasNext()){
    i = i + 1;
    SectionContentsBean part = iter.next();
    SelectItem selection = new SelectItem();

    // need to filter out all the random draw parts
    if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
      // skip random draw parts, cannot add items to this part manually
    }
    else {
      if ("".equals(part.getTitle())) {
        selection.setLabel(rb.getString("p")+" "+ i );
      }
      else {
        selection.setLabel(rb.getString("p")+" " + i + " - " + ComponentManager.get(FormattedText.class).convertFormattedTextToPlaintext(part.getTitle()));
      }
      selection.setValue(part.getSectionId());
      list.add(selection);
    }

  }


  Collections.reverse(list);
  // create a new part if there are no non-randomDraw parts available
  if (list.size() <1) {
    i = i + 1;
    SelectItem temppart = new SelectItem();
    temppart.setLabel(rb.getString("p")+" "+ i );
    temppart.setValue("-1");  // use -1 to indicate this is a temporary part. if the user decides to cancel the operation, this part will not be created
    list.add(temppart);
  } 
  

  return list;
}
 
Example 17
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public List getSectionSelectList() {
  List list = new ArrayList();
  
  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
  AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
  List<SectionContentsBean> sectionSet = assessbean.getSections();
  Iterator<SectionContentsBean> iter = sectionSet.iterator();
  int i =0;
  while (iter.hasNext()){
    i = i + 1;
    SectionContentsBean part = iter.next();
    SelectItem selection = new SelectItem();

    // need to filter out all the random draw parts
    if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
      // skip random draw parts, cannot add items to this part manually
    }
    else {
      if ("".equals(part.getTitle())) {
        selection.setLabel(rb.getString("p")+" "+ i );
      }
      else {
        selection.setLabel(rb.getString("p")+" " + i + " - " + ComponentManager.get(FormattedText.class).convertFormattedTextToPlaintext(part.getTitle()));
      }
      selection.setValue(part.getSectionId());
      list.add(selection);
    }

  }


  Collections.reverse(list);
  // create a new part if there are no non-randomDraw parts available
  if (list.size() <1) {
    i = i + 1;
    SelectItem temppart = new SelectItem();
    temppart.setLabel(rb.getString("p")+" "+ i );
    temppart.setValue("-1");  // use -1 to indicate this is a temporary part. if the user decides to cancel the operation, this part will not be created
    list.add(temppart);
  } 
  

  return list;
}