This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes struts2 + display tags +  maps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 + display tags +  maps" Watch "struts2 + display tags +  maps" New topic
Author

struts2 + display tags + maps

vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
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
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

Whats the error. Do you have a getter for that map?
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
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

Joined: Mar 10, 2010
Posts: 122

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

vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
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

Joined: Mar 10, 2010
Posts: 122

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

Joined: Sep 11, 2006
Posts: 170
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

Joined: Mar 10, 2010
Posts: 122

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

Joined: Sep 11, 2006
Posts: 170
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

Joined: Sep 11, 2006
Posts: 170
Hi all,

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



The above code works absolutely 100% Yipeee


regards,
Vanlal
Aniket Kumbhoje
Greenhorn

Joined: Aug 09, 2012
Posts: 2
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2 + display tags + maps
 
Similar Threads
Struts2
Struts2 with Displaytag export option is not working
Struts2 + display tag
maintin checkbox stauts during paginatin(dispalytag)
struts display properties