jsp - enums are being interpreted as Strings -


i setting sessionscope object when user logs in, , bean object composed of couple of other beans. 1 of properties these beans enum, found out el cannot properties of enum class, , can properties of java bean object. decided make bean class enum, , have enum nested in bean class. java bean made replace enum can values el looks this:

public class rankbean implements serializable {      private static final long serialversionuid = -1;      private string rankname;      public rankbean(string rankname) {         this.rankname= rankname;     }      public rankbean(rank rank) {         this.rankname = rank.getrankname();     }      public string getrankname() {             return rankname;         }      public void setrankname(string rankname) {         this.rankname = rankname;     }      public static enum rank {         rank_1("some rank name"),         rank_2("some rank name"),         rank_3("some rank name"),         rank_4("some rank name"),         rank_5("some rank name"),         rank_6("some rank name"),         rank_7("some rank name"),         rank_8("some rank name");          private string rankname;          private rank(string rankname) {             this.rankname = rankname;         }          public string getrankname() {             return rankname;         }          public static rank getrank(string rankname) {             (rank rank : rank.values()) {                 if (rank.getrankname().equals(rankname)) {                     return rank;                 }             }             return null;         }          @override         public string tostring() {             return rankname;         }     } } 

however, when try access rank name (or ever property there may be), still jsp error saying rank object string , property named rankname not exist in java.lang.string. same problem had when trying properties of enum directly, not. here error message:

javax.el.propertynotfoundexception: property 'rankname' not found on type java.lang.string 

so following el cause error because rankname apparently doesnt exist.

${sessionscope.account.player.rank} 

i can not see setter method of rankname in above code.

public void setankname(string rankname) {    this.rankname = rankname;     } 

i think setrankname


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -