1 Reply Latest reply on Jan 10, 2008 4:26 AM by Tony Herstell

    s:selectItems  and  convertEnum  and order of enum retention

    Tony Herstell Master

      Given

      <h:selectOneRadio id="booking_duration_selection" value="#{bookingController.duration}" layout="pageDirection">
       <s:selectItems value="#{bookingController.getBookingDurationsKind()}" var="bookingDurationKind" label="#{messages[bookingDurationKind.inlLabel]}"/>
       <s:convertEnum />
       <a4j:support event="onclick" reRender="bookingCourseType, resourceAddButtons, resourceAddedTable" />
      </h:selectOneRadio>
      


      Backed by
       public enum BookingDurationsKind {
       ONE_HOUR_PRIVATE ("booking_1hrprivate"),
       ONE_HOUR_OPEN ("booking_1hropen"),
       COURSE ("booking_course");
       private final String inlLabel;
       BookingDurationsKind(String inlLabel) {
       this.inlLabel = inlLabel;
       }
       public String getInlLabel() { return inlLabel; }
       }
      


      Can I somehow retain the order of the enum when its displayed as checkboxes? There is no attribute etc...


      On the screen I get:
      Open 1 Hour Booking (anyone may book the same slot within system limit of 6 people!)
      Private 1 Hour Booking
      Course Booking
      


      Where private booking should be topmost.



        • 1. Re: s:selectItems  and  convertEnum  and order of enum reten
          Tony Herstell Master

          Please ignore...
          I caused it.. I had the lines below in the wrong order.

          @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
          public List<BookingDurationsKind> getBookingDurationsKind() {
           List<BookingDurationsKind> allDurationKinds = new ArrayList<BookingDurationsKind>();
          
           allDurationKinds.add(BookingDurationsKind.ONE_HOUR_PRIVATE);
           allDurationKinds.add(BookingDurationsKind.ONE_HOUR_OPEN);
          
           allDurationKinds.add(BookingDurationsKind.COURSE);
           return allDurationKinds;
          }