Hello Simon,
Your approach is to give the Element in the backing bean the value, like this:
The bean has the List with the Wrapped Items and one of the items you want to
set with the List in it:
private List<SelectItem> indexTypesForSuche;
private GeVoSuchtyp selectedIndexType;
public List<SelectItem> getIndexTypesForSuche() {
return indexTypesForSuche;
}
public GeVoSuchtyp getSelectedIndexType() {
return selectedIndexType;
}
public void setSelectedIndexType(GeVoSuchtyp pSelectedIndexType) {
selectedIndexType = pSelectedIndexType;
}
Then, I would preselect the Object with a value from the List in the
constructor:
public DokumentSuchenBean() {
indexTypesForSuche = new ArrayList<SelectItem>();
for (Iterator<GeVoSuchtyp> iterator =
jFlowBean.getCodePool().getGeVoSuchtypListe().iterator();
iterator.hasNext();) {
GeVoSuchtyp lSuchtyp = iterator.next();
indexTypesForSuche.add(new SelectItem(lSuchtyp, lSuchtyp
.toString(), lSuchtyp.toString(), false));
}
if(setSelectedIndexType.size>0) {
setSelectedIndexType(indexTypesForSuche.get(0).getValue())
}
}
The jspx would look like this:
<tr:selectOneChoice value="#{DokumentSuchenBean.selectedIndexType}" >
<f:selectItems value="#{DokumentSuchenBean.indexTypesForSuche}"/>
</tr:selectOneChoice>
Mit freundlichen Grüßen
Tobias Eisenträger
Softwareentwickler
Dokumentenmanagement/Workflow/Internet, AKB 8125
ARAG IT GmbH
ARAG Platz 1, 40472 Düsseldorf
Tel.: +49 (0)211 964-1937
[email protected]
www.ARAG.de
Aufsichtsratsvorsitzender:
Gerd Peskes
Vorstand:
Dr. Paul-Otto Faßbender (Vors.),
Dr. Jan-Peter Horst,
Dr. Johannes Kathan, Werner Nicoll,
Hanno Petersen, Dr. Joerg Schwarze
Sitz und Registergericht:
Düsseldorf, HRB 1371
USt-ID-Nr.: DE 119 355 995
> -----Ursprüngliche Nachricht-----
> Von: schneidc [mailto:[email protected]]
> Gesendet: Donnerstag, 25. Februar 2010 16:20
> An: [email protected]
> Betreff: [TRINIDAD] SelectOneChoice preselection possible?
>
>
> Hi,
>
> at first I was using the default JSF 1.2 ComboBox (selectOneMenu) but then
> switchted to the Trinidad equivalent (selectOneChoice) to get Ajax
> functionality.
>
> So far it's working fine, the only thing bothering me in comparison to the
> selectOneMenu is, that the default selection is an empty element but I'd
> like to have the first element of the bound list of SelectItems to be
> preselected.
>
> I tried it via setting the value of the selectOneChoice to the first
> element
> of the list in the constructor of the bean, but that didn't work.
> So is it even possible to make a preselection? And if so, how to achieve
> it?
>
>
> Cheers
> Simon
> --
> View this message in context: http://old.nabble.com/-TRINIDAD--
> SelectOneChoice-preselection-possible--tp27714456p27714456.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.