我正在努力想出一个能在列中找到两个值的Expression。我正在使用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;
}
}
非常感谢任何帮助!
答案 0 :(得分:0)
我的同事找到了解决方案:
"not (personData.status not in (#{personSortDataList.statusChoice == 'B' ? "
+ "'A' : null})",
"personData.status not in (#{personSortDataList.statusChoice == 'B' ? "
+ "'I' : null}))",
到目前为止这是正常的