Tuesday, January 20, 2015

HOW TO USE ENUM IN STRUTS2 SELECT TAG


Set OGNL (Object-Graph Navigation Language ) true in struts.xml file

struts.xml

<constant name="struts.ognl.allowStaticMethodAccess" value="true" />


Enum

package com.raj.controller.pkg;

public enum PkgStatusConstants {


ACTIVE("Active"),
INACTIVE("Inactive");

  public final String val;

PkgStatusConstants(String val){
this.val = val;
}
 

}

Select Tag in Jsp

<s:select name="pkgData.status" key="getText('pkg.status')" list="@com.raj.controller.pkg.PkgStatusConstants@values()" cssClass="form-control" />

Keep Visiting
Write your Comment

2 comments:

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...