2 Replies Latest reply on Jun 14, 2007 4:42 AM by Fredric

    Enums in JSF code

    Fredric Newbie

      Hi,
      I have a xhtml file where I try to use an enum I've created for my system. The enum works when I use it to set values on entities' properties and can also print the enum, set as a value in an entity, in the xhtml file.

      But I can't seem to be able to create a rendered condition or print a value directly from the enum #{PStatus.ACTIVE}

      My enum:

      @Name("pStatus")
      public enum PStatus {
       INITIATED(0), ACTIVE(1), DRAWING_DONE(2), CLOSED(3);
      
       private int value;
      
       private PStatus(int value) {
       this.value = value;
       }
      
       public int getValue() {
       return(value);
       }
      }



      Part of my xhtml file:
      <h:column rendered="#{bookable.week.period.status == PStatus.ACTIVE}">
      <h:commandLink action="#{subscriptionView.sortBy('email')}" value="Vinnare"/>
      </h:column>


      What am I missing here?



        • 1. Re: Enums in JSF code
          Pete Muir Master

           

          "Frippe" wrote:
          <h:column rendered="#{bookable.week.period.status == PStatus.ACTIVE}">
          </h:column>


          This isn't valid EL, EL has no support for accessing enum's - something like #{bookable.week.period.status == bookable.month.period.status} would work though (where you compare two instance values of enums).

          You can probably write a facelets function to do this. And yes, this is on my wishlist for EL as well!

          • 2. Re: Enums in JSF code
            Fredric Newbie

            Ok, thanx. I'll try another approach now and hope to get this working in a later version of EL.

            Thanx,
            Fredric