【发布时间】:2013-11-23 03:54:15
【问题描述】:
我正在尝试使用 JSF 解决这里的一些问题,但我没有运气。我会尝试恢复我的代码,因为我不认为这里的很多代码可以帮助你解决这个问题,所以我会尝试更好地描述我的问题。
现在我有一个存储三个班次的字符串:matutinal、vespertine 和 nightly。在我的架构中,我需要myStringArray[0] = 'matutinal'、myStringArray[1] = 'vespertine' 和myStringArray[3] = 'nightly'。
我在我的应用程序中使用 JSF 2.0 和 Primefaces - 也有一些 omnifaces。
以下是我的 JSF 代码:
<p:selectManyCheckbox value="#{escolaMBean.turnos}">
<f:selectItems value="#{escolaMBean.listaTodosTurnos}" var="turno" itemValue="#{turno.nome}" itemLabel="#{turno.nome}" />
</p:selectManyCheckbox>
escolaMBean 中的注释:
// Stores the selected "Turnos" (This means "shift" in English)
String[] turnos = new String[3];
// Stores all the "Turnos" received from DB
ArrayList<Turno> listaTodosTurnos = <myControl.myDbRequest()>
/*
* Turno have a simple ID and Name, in DB we have 3 "Turnos": Matutinal, Vespertine, Nightly
* In this MBean I have all getters and setters - and in "Turno" class too.
* When I set one string in turnos[n], this set the right value
*/
因此,基于这些事情,如果选择了 matutinal 复选框,我如何选择 turnos[0],如果选择了 vespertine 复选框,我如何选择 turnos1,如果选择了每晚复选框,我该如何选择 turnos[2]?现在这不起作用,因为如果我先选择 Nightly,则位置 turnos[0] 将等于“nigthly”。
我该如何解决这个问题?
【问题讨论】:
标签: arrays jsf jsf-2 primefaces selectmanycheckbox