我正在尝试提出一个表达式,它将在一列中找到两个值。我正在使用 JBoss 4.2.2、JSF 1.2、RichFaces 3.3。
在这两个单独的例子中:
"personData.status in (#{personSortDataList.statusChoice == 'A' ? "
+ "personSortDataList.statusChoice : null})",
"personData.status in (#{personSortDataList.statusChoice == 'I' ? "
+ "personSortDataList.statusChoice : null})",
它工作得很好。当我尝试将它们结合起来时:
"#{personSortDataList.statusChoice == 'B' ? "
+ "(personData.status in (A, I) : null})", // Done this several different ways
我不知道使用什么类型的表达式来拉入 A 和 I。这些查询附加到 h:selectOneRadio:
<h:panelGrid columns="2">
<b>#{messages['Status']}: </b>
<h:selectOneRadio layout="lineDirection"
value="#{personSortDataList.statusChoice}">
<f:selectItem itemLabel="#{messages['Active']}" itemValue="A" />
<f:selectItem itemLabel="#{messages['Inactive']}" itemValue="I" />
<f:selectItem itemLabel="#{messages['Active and Inactive']}" itemValue="B" />
</h:selectOneRadio>
</h:panelGrid>
对于bean,我有(除了查询):
@Name("personSortDataList")
public class PersonSortDataList extends EntityQuery<PersonData>
{
private static final long serialVersionUID = 1L;
...
private Character statusChoice;
...
private static final String EJBQL = "Select personData From PersonData personData";
private static final String[] RESTRICTIONS =
{
...
"personData.status in (#{personSortDataList.statusChoice == 'A' ? "
+ "personSortDataList.statusChoice : null})",
"personData.status in (#{personSortDataList.statusChoice == 'I' ? "
+ "personSortDataList.statusChoice : null})",
"#{personSortDataList.statusChoice == 'B' ? "
+ "(personData.status in (A, I) : null}",
...
};
public CIMinMax ciMinMax;
public CIMinMax getCiMinMax()
{
return ciMinMax;
}
public void setCiMinMax(CIMinMax ciMinMax)
{
this.ciMinMax = ciMinMax;
}
private PersonData personData;
public PersonSortDataList()
{
personData = new PersonData();
personData.setId(new PersonDataId());
ciMinMax = new CIMinMax();
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(Integer.valueOf(300));
}
public PersonData getPersonData() {
return personData;
}
public void setPersonData(PersonData personData) {
this.personData = personData;
}
@Override
protected String getCountEjbql()
{
setUseWildcardAsCountQuerySubject(true);
return super.getCountEjbql();
}
...
public void setStatusChoice(Character statusChoice) {
this.statusChoice = statusChoice;
}
public Character getStatusChoice() {
return statusChoice;
}
}
任何帮助是极大的赞赏!