Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-06-2007, 01:34 PM
Member
 
Join Date: Nov 2007
Posts: 2
sathya_k_83 is on a distinguished road
how to populate html:select with values from database
i am developing a struts project.

The employee Login table has
1)EmpId , EmpName , RoleId.
i want to read the roleid from the RoleTable(DB)
and populate in the employee Login Form

can any one tell me how to populate the from Data base
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-07-2007, 11:53 AM
Member
 
Join Date: Nov 2007
Posts: 3
JavaThinker is on a distinguished road
Use Custom Tag Libraries
Hi,

This could be achieved using custom tag libraries.

It is a 3 step process:-

1. Prepare a TLD file, with the details of the tag you wish to create. For example, name "roleselect" and tagclass as "myapps.trial.RoleSelect".
2. Implement the tagclass "myapps.trial.RoleSelect" extending TagSupport. You will need to implement 2 methods - doStartTag() and doEndTag(). In these methods, you may query the database for the values of roleid and use these to prepare the HTML code for Select. Finally, out put this HTML code to a JSPWriter.
3. In you JSP file, include the tag library(TLD file) by specifying the TLD file path in your taglib attribute like this:
<%@ taglib url=".. GIVE PATH OF YOUR TLD FILE .." prefix="my" %>
Then, the roleid select dropdown can be obtained by simple putting <my:roleselect /> at the appropriate place in the JSP file.

I hope that gives you some idea of how you could get started. You may need to do some more study JSP custome tags.

Regards,
JavaThinker
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting values from database in dropdown aa74 JavaServer Pages (JSP) and JSTL 1 04-21-2008 11:00 PM
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 02:04 PM
Displaying a Java List in Html:select tag ramitmehra123 New To Java 0 02-07-2008 06:48 AM
Getting HTML form values in Servlet Java Tip Java Tips 0 11-17-2007 09:13 PM


All times are GMT +3. The time now is 07:16 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org