aspose file tools*
The moose likes JSP and the fly likes Populating Country Values in combobox using spring form tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Populating Country Values in combobox using spring form tags" Watch "Populating Country Values in combobox using spring form tags" New topic
Author

Populating Country Values in combobox using spring form tags

ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

I am unable to display country list from database on my jsp page. Instead of the country values, i am getting the below output onm my jsp page

-----------Output Start---------------------
Project.Domain.Admin.CountryService@d6a0e0 Project.Domain.Admin.CountryService@dbf04d
-----------Output End-----------------------

The code on my jsp page is as under.

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ include file="/WEB-INF/jsp/Admin/include.jsp" %>

<core:forEach var="county" items="${CountryList}">
<coreut value="${county}"/>
</core:forEach>

I am using spring Controller & i am sending the List object in HttpRequest parameters of ModelAndView return type.


Regards,

Ujjwal Soni


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Jason Ferguson
Ranch Hand

Joined: Sep 16, 2007
Posts: 47
Okay, first some nitpicking:

You are mixing "county" and "country" as names. This can lead to massive confusion since the words are similar but have different meanings.

Now, I'm assuming that you have a Domain Object named Country, with fields such as "id","name" (or "countryname"), etc. However, in your Expression Language (EL) in <coreut name="">, you are specifying the entire object. This is calling the default "toString()" of that object.

Instead, use an EL something like this: ${country.name}, specifying which attribute of the country object to output.

Also, in order to keep myself consistent, I usually create an interface for my Domain Objects:



I tend to use alot of dynamically created <option> tags, and one of the things this interface allows me to do is always know what the option tags will be populated with. (Also, sometimes I just get going too fast and will name my id and name fields badly).

Jason

Originally posted by ujjwal soni:
Hi,

I am unable to display country list from database on my jsp page. Instead of the country values, i am getting the below output onm my jsp page

-----------Output Start---------------------
Project.Domain.Admin.CountryService@d6a0e0 Project.Domain.Admin.CountryService@dbf04d
-----------Output End-----------------------

The code on my jsp page is as under.

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ include file="/WEB-INF/jsp/Admin/include.jsp" %>

<core:forEach var="county" items="${CountryList}">
<coreut value="${county}"/>
</core:forEach>

I am using spring Controller & i am sending the List object in HttpRequest parameters of ModelAndView return type.


Regards,

Ujjwal Soni
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating Country Values in combobox using spring form tags
 
Similar Threads
Returning List Object but not able to display value using Spring c:foreach tag
JSTL forEach Tag not working
Populating Country Values in combobox using spring form tags
Reading from Map in jstl
Expression Language not evaluating generic Java Map and list as desired