2 Replies Latest reply on Jun 26, 2007 1:02 PM by dsmith1

    howto: selectManyMenu and hql with EntityQuery

    thegernot

      Hello,
      I have used seam gen to generate basic classes for an existing database model. Now I try to add a listbox with multiple selection. The backend class is extended from EntityQuery.
      The problem I have now:
      How can I add a multiple selection restriction string for the query?

      I have tried with a Long[] but the result is a class cast exception: the resulting select is not capable that he should receive a list but expects only one variable instead...

      <h:selectManyMenu value="#{parameterList.categoryIds}">
       <s:selectItems value="#{paramcategoryList.resultList}" var="category" label="#{category.name}"/>
       <s:convertEntity />
      </h:selectManyMenu>
      

      @Name("parameterList")
      public class ParameterList extends EntityQuery {
       private List<Long> categoryIds;
      
       private static final String[] RESTRICTIONS = {
       "parameter.paramcategory.id in elements(#{parameterList.categoryIds})",};
      
       @Override
       public String getEjbql() {
       return "select parameter from Parameter parameter";
       }
      
       @Override
       public List<String> getRestrictions() {
       return Arrays.asList(RESTRICTIONS);
       }
      
       ... categoryIds getter and setter
      }
      


      An additional problem arises with building RESTful URL's: since I have a dynamic list of parameters for the GET URL I have not found a solution to add a suitable page parameter to page.xml. As a work around I use the JSF POST...
      Does anybody know how to add a page parameter that is capable of a selection list?

      Many thanks,
      Gernot