• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

I wanted to populate "id" as value and "employeeName" as a name <s:select> in struts 2

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<h1>**In my project i am using Struts2, Spring2.5 and JPA(Hibernate)**<h2>

my "**EmployaaDaoJpa**"


Query query = entitymanager.createQuery("SELECT e.employeeName FROM Employee e");
List<String> lstEmployee = query.getResultList();

- using this i am getting all the employee names. and in my action class i will get all the states, both are declared in my VO (I implemented ModelDriven)

List<String> lstEmployees;
String yourEmployee;

in the action class i will initialize the lstStates like

lstEmployees = employeeDao.getAllEmployees();

and in my jsp

<s:select headerKey="" headerValue="--- Select ---" list="states" name="yourEmployee" key="addEmployee.yourEmployee" required="true" cssClass="input"></s:select>

when i run this with server then it will generate html code, in that i am getting
value of the list and name of the list as same, like,

<select name="yourEmployee" id="AddEmployeeAction_yourEmployee" class="input">
<option value="">--- Select ---</option>
<option value="XYZ">XYZ</option> //(Here value and name are same "XYZ"
<option value="ABC">ABC</option> //(Here value and name are same "ABC"
<option value="MJJ">MJJ</option> //(Here value and name are same "MJJ"
</select>

my problem is that, i wanna set employeeId as value and employeeName as name..

**So, if anyone know about this please help me...**


**Thanks in advance....**
 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From struts2 doc
listKey -> used as key
listValue -> used as value
key -> Set the key (name, value, label) for this particular component
 
reply
    Bookmark Topic Watch Topic
  • New Topic