2

I'm trying to come up with an Expression that will find two values within a column. I'm using JBoss 4.2.2, JSF 1.2, RichFaces 3.3.

In these two single examples:

    "personData.status in (#{personSortDataList.statusChoice == 'A' ? " 
        + "personSortDataList.statusChoice : null})", 

    "personData.status in (#{personSortDataList.statusChoice == 'I' ? " 
        + "personSortDataList.statusChoice : null})",

It works great. When I try to combine them:

        "#{personSortDataList.statusChoice == 'B' ? " 
        + "(personData.status in (A, I) : null})", // Done this several different ways

I can't figure out what type of expression to use to pull in both A and I. These queries are attached to 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>

For the bean, I have (other than the queries):

    @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;
    }
}

Any help is greatly appreciated!

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
mikjall77
  • 51
  • 2
  • 1
    @maple: Forgive me my EJB-QL ignorance, but I don't think that it's using regex. I believe that the OP is confusing "regular expression" with "expression language" (EL). – BalusC May 23 '11 at 19:48
  • I don't do EJB-QL, but it makes perfect sense to me if you quote string/enum values in EL. E.g. `in ('A', 'I')`. Give it a try. – BalusC May 23 '11 at 19:49
  • @BalusC Thanks for the comments! I believe you are correct with it being EL and not Regex. I have tried the ('A', 'I') with no luck. In a worst case scenario (which might be best case in this instance) I'll just write out the entire EJBQL. Thanks again :) – mikjall77 May 24 '11 at 13:24

1 Answers1

0

My coworker found a solution:

"not (personData.status not in (#{personSortDataList.statusChoice == 'B' ? " 
       + "'A' : null})",

"personData.status not in (#{personSortDataList.statusChoice == 'B' ? " 
       + "'I' : null}))", 

This works correctly so far

mikjall77
  • 51
  • 2