• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts2 + display tags + maps

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using struts2 + display tags for pagination.
In my StudentAction.java, i have qualificationMap which has a mapping qualification code with qualification name.



In my query.jsp, the following is the display part


1. I am only able to display the qualification code and not the qualification name using display:column
2. The qualification name is the one that needs to displayed.


Regards,
Vanlal
 
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the error. Do you have a getter for that map?
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i have a getter and setter ...
If i use the struts property like below , i am able to get the value


I can display qualification code like below



But i don't know how to combine this with display tags..

Regards,
Vanlal
 
Jesus Mireles
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried setting the value to some variable as so:

 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucas,


The above line will give me some integer values like 2,3,4 etc...


Map ===> 2 , Graduate
3, P.G.

The below will give me the string value mapped to this integer in struts tag


So, i do not know how to do this using display tags ....





Regards,
Vanlal
 
Jesus Mireles
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again ... since you can get the value using just struts tags im saying to set the value to some variable and using it in the display tag.


Lucas Mireles wrote:Have you tried setting the value to some variable as so:

 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucas,

Lucas Mireles wrote:

Lucas Mireles wrote:Have you tried setting the value to some variable as so:



This doesn't work .. the number inside qualificationMap varies from record to record.


Error : "value" does not support runtime expression.

regards,
Vanlal

 
Jesus Mireles
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I obviously have very little understanding of your actual project/problem ... so i'm going to assume some things in my response but maybe what you need to do is provide a getter in your student object like getQualificationName which takes the qualification code and returns the mapped value. My understanding is that this student object has some codes which in turn you have mapped to display values which you are keeping in a map.

This should solve the problem if I'm understanding correctly ...
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lucas,

I am using struts2 + hibernate for the current project ...
I cannot just put a getter / setter / object in my Student class because this in turn will be mapped with the database <Hibernate used here>
I have a List<Student> which will contain student's details. this is student's table.
Eg
"std_fname"-"std_lname"-"father_name"-"qualification_code"-"contact_no"-"address"-"gender"-"category"
Johnny-Quest-Ramos-12-93232323-LA-Male-General

Qualfication code is mapped with a qualification name .. i.e 1->BE , 2->ME etc... This is a seperate table ...

Using struts tags , this will work when iterating each and every record in the studentList .
My StudentAction class contains getters for qualificationMap


Now when i am using displaytags , i iterate over the studentList, but when i come to qualification_code

This will give me only the integer part for each and every student ... This values keeps on changing for each and every student.
So i cannot just set one value.

But i want to display the mapped name from qualficationMap which is inside my StudentAction class.

So i tried combining different things like the qualificationMap[qualification_code] but it does not work.

Hope that you'll be able to understand the problem.
If i just know how to get the dynamic value in the display tag and get the mapped value from the Map, this will defenitely solve the problem.

Regards,
Vanlal



 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

After spending lots and lots of hours on this , finally got the solution ..



The above code works absolutely 100% Yipeee


regards,
Vanlal
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also working on display tag but i have small problem..i am giving my code below..



but i want different format which is not working..


above example i want to display first name and last name in one column...please any one give me solution Thanks in Advance..
 
reply
    Bookmark Topic Watch Topic
  • New Topic