Home Answers Viewqa Struts ultiple selections list in Struts

 
 


Clark
ultiple selections list in Struts
1 Answer(s)      2 years and 6 months ago
Posted in : Struts

How to create a multiple selections list in Struts? and retrive seleted values ?

View Answers

November 20, 2010 at 11:44 AM


Hi friends,

With the help of this example, you can display multiple selections list and how to access selected values in struts. bookList list contains list of Book objects.

Java bean class.

public class Book{
int  bookId;
String bookName;


public int getBookId() {
    return medId;
}

public void setBookId(int bookId) {
    this.bookId = bookId;
}

public String getBookName() {
    return bookName;
}

public void setBookName(String bookName) {
    this. bookName =  bookName;
}

}

In the Form Class :

public class BookForm {
private List bookList;
private String[] book;
public void setBookList(List medList){
    this.bookList = bookList;
}

public List getBookList(){
    return this.bookList;
}

public String[] getBook() {
    return book;
}

public void setBook(String[] book) {
    this.book = book;
}

}

In the Action class :

List medList = DAO.getBooks(); form.setBookList(bookList);

DAO Class :

DAO Class to retrieve Books in data base.

  public static List getBooks(){
    PreparedStatement pStmt = null;
 Connection con = null;
 boolean success = false;
 ResultSet rs = null;
 List bookList = new ArrayList();

 try{
     conn = getConnection();

     String sql = " select * from BOOK ";
     pStmt = conn.prepareStatement(sql);

     rs = pStmt.executeQuery();
     while(rs.next()){
         Book book= new Book();
         book.setBookId(rs.getInt("Book_ID"));
         book.setBookName(rs.getString("Book_NAME"));
         bookList.add(book);
         }               
 }catch(Exception e){
     e.printStackTrace();

 }finally{
     closeConnectionProp(conn,pStmt,rs);
 }        
 return bookList;    
}

JSP Struts page:

<html:select name="BookForm" property="book" multiple="true">

<bean:define name="BookForm" property="BookList" id="bklist" />
<html:options collection="bklist" property="bookId" labelProperty="bookName" />
</html:select>

In the Action class again :

how to retrieve the selected values.

String[] book= form.getBook();

Thanks.









Related Pages:
ultiple selections list in Struts
ultiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
multiple selections list in Struts
multiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
drop down list in Struts
drop down list in Struts  How to create a drop down list in Struts
struts dropdown list
struts dropdown list   In strtus how to set the dropdown list values... page using struts ? please send me jsp code... sample code: **Action... = MasterDataDAO.getValues(list); request.setAttribute("masterlist", masterList
contains for list in struts2 - Struts
contains for list in struts2  Is there any way to check in the list or for existence of an enum ? Something like list.contains(string). iterating over list I want to do something like Display x display y
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble sorts and selections sorts  I can get both of the sorts figured out but i... many words he/she types without using an array list.   Thank you. I
creating list in dropdown using struts - Struts
creating list in dropdown using struts   creating list in dropdown using struts : In action class list.add(new LabelValueBean("ID","Name")); In Jsp * Select Item Select In Form : getter
Select functionality of drop down list - Struts
(in struts application) in which if user select HIDE from the drop down list... have Drop down list having element Test1,Test2,Test3,HIDE and one Text msg box for entering Age,Now if user select "HIDE" from drop-down list the below text
using getText(String aTextName, List args) - Struts
using getText(String aTextName, List args)   What should my pacakge.properties (Message.properties) should have ? basically i am trying to use ActionSupport.getText(String aTextName, List args) I want something like "you
struts - Struts
struts  Hi, i want to develop a struts application,iam using eclipse... files where i have to keep them,and war files.(tell me the list of jar&war files... functionality u want to use in your project. There is no standard list of jar files
How to handle the list dynamically in struts inside logic:iterate tag
How to handle the list dynamically in struts inside logic:iterate tag ...; </table> my struts config with dyna form is: <form-bean name...; In my action I wish to take the values from list named inutParamsvalues
Struts Articles
' mailing list, the Struts developers' mailing list, and my experience with Struts... Struts Articles Building on Struts for Java 5 Users Struts is undoubtedly the most successful Java web
List
List  i do have one list object, i want to compare this list from database table and if match found i want to update the list
Struts,JSP - Struts
Struts,JSP  I'm facing problem while using logic:iterate to render the data in the jsp from the Array list. javax.servlet.ServletException: Cannot find...("uname",employees); In the jsp
List
List  getting values from a form and make a list of them and store them into database
dropdown in struts - Struts
in struts application when i have the workflow as jsp->acton->Business... write the query (in which file)to get the list from database and how and where can i set the list to context to get it from there in a collection object
Javascript List Box - JSP-Servlet
Javascript List Box  Thanks vdeepak for sending answer.But i tried ur example but i failed.actuall am doing in struts 1.1. this is my code... itself.my problem is in list box the semester which i selected is not showing
Struts 2.0 - Struts
Struts 2.0  Hi ALL, I am getting following error when I am trying to use tag. tag 'select', field 'list': The requested list key 'day' could...; private List day; public String execute()throws Exception
Enabling Row, Column and Cell Selections in a JTable
Enabling Row, Column and Cell Selections in a JTable... to describe how to enable the row, column and cell selections in a JTable... will see the enabling row, column and cell selections in a JTable. When you
file download in struts - Struts
need to get an error message when no meterid is selected from the list... I used validator in struts but it didn't worked... i used validate() in form bean... entered into the page n the list content are invisible... HOw can i validate
awt list item* - Swing AWT
"); choice.add("Struts"); List lst = new List(4, false); lst.add...awt list item*  how do i make an item inside my listitem... frame=new Frame("Add list"); Label label=new Label("What is your Choice
java - Struts
java  i want to display a list through struts what code i writen in action, class , struts config.xml and jsp please tell me thnks for solving my probelm  Hi friend, To solve the problem to visit this link
Need acode for struts implementation - Struts
Need acode for struts implementation  I want a code to generate dynamic table with a text field and a drop down list and to retrieve that data in the action class and store in the data base
Select from select list + display
Select from select list + display  i have a select list containing... select EmpCode from the select list, the corresponding EmpName and DeptName should be displayed automatically in empty text fields. I am using struts 1.2
scroll bars to list box - JSP-Servlet
scroll bars to list box  Can I add scroll bars to a list box in struts?  Hi friend, Scroll the list box in struts Two attribute set "multiple" "size". Select Tag Example Select Tag
JSP - Struts
JSP  am using struts frame work for my project, my requirement is 1.in jsp page Class(drop down list) will take all classes in school from database... another list of values of students names. 3.when we select any student i want
JSP - Struts
JSP  am using struts frame work for my project, my requirement is 1.in jsp page Class(drop down list) will take all classes in school from database... another list of values of students names. 3.when we select any student i want
JSP - Struts
JSP  am using struts frame work for my project, my requirement is 1.in jsp page Class(drop down list) will take all classes in school from database... another list of values of students names. 3.when we select any student i want
eclipse - Struts
Eclipse keyboard shortcuts  I need a list of eclipse keyboard shortcuts.Thanks
Struts 2 IDE
Struts 2 IDE This page contains the list of IDEs available to ease the development of Struts 2 Framework based applications. The IDE for Struts 2 will actually make the development cycle much easier. Here are the list of Struts 2
multiboxes - Struts
in javascript code or in struts bean.  Hi friend, Code to solve
Struts 2 Eclipse Plugin
Struts 2 Eclipse Plugin       This page contains the examples and the list of plugins that are available for Struts 2... for Struts 2. You can view the status of the project at http://akrogen.sourceforge.net
Using radio button in struts - Struts
Using radio button in struts  Hello to all , I have a big problem that i am trying to solve. Here are the details : I have a list of TV's... source code to solve the problem : For more information on radio in Struts
datetimepicker - Struts
Datetimepicker in Struts  Hi, I have une jsp page with a list of datetimepicker. When I submit the form, there is an offset (lag) in array. Date[0] => Date[3] Date[1] => Date[0] Date[2] => Date[1] etc... I don't know
j2ee - Struts
j2ee  How to get values from a database which is stored in form1 in to form2 with in a listbox. pls help me.  Hi bhaskar, You have to write database related code in the form itself in which the list box is present
For Loop - Struts
For Loop  Hi, How to use for loop in Struts2. I don't want use Java code in the JSP. In my application I am using List is sending to jsp ffom Action class. In jsp i am iterating through the Iterator. the List
Struts2 - Struts
Struts2  S:select tag is being used in my jsp, to create a drop down list. The drop down works very well in Mozilla, but in IE7 it behaves very...: public List getState(){ state = new ArrayList(); state.add("Alabama
Regarding struts tag and struts dojo tags.
Regarding struts tag and struts dojo tags.  Hi, in the auto completer example, auto completer tag is of dojo library. So how does prefix of struts...:autocompleter theme="simple" list="fromLocation" name="StateName"/></td>
Struts Video Tutorials
technologies. Here are the list of Struts 2 Video Tutorials: How...Struts Video Tutorials - Now you can learn the Struts programming easily and in less time. Struts Video tutorials are very extensive and explained
struts property file query
struts property file query  hi i hav 3 property file in my struts2 application. how can i tell my struts application to read a particular property file based on the language i select from the dropdown list. Please help
struts collection problem in Mozilla
struts collection problem in Mozilla   I used the to get list of records, if records are more than 15-20 then this is not seen properly with vertical scroll bar on Mozilla. Plz help me
Struts 2.0.1
Struts 2.0.1       Now the new release of Struts 2 framework is available with new features and enhancements. Now there is no need to add struts-default.xml in struts.xml file. The struts-default.xml
Struts 2.0.0
Struts 2.0.0       The Struts 2.0.0 is the first version of Struts. Struts 2.0 is based on Web works and now its part of Apache Struts. Struts framework has been the most popular and widely used
struts based - Java Beginners
Struts select field from database  I have a login page Customer name,fiscal year,fiscal month from ,fiscal month to. I want to select the name from data base(when i click on list of value) and i put the calender on Fiscl year
Drill down in Struts 2.0.14
Drill down in Struts 2.0.14  Hello Tutor, I am developing my project in Struts 2.0.14. I have to make drill downs in the form of tree structure.... For Example, I have many countries list in which drilling down by country gives my its
Drill down in Struts 2.0.14
Drill down in Struts 2.0.14  Hello Tutor, I am developing my project in Struts 2.0.14. I have to make drill downs in the form of tree structure.... For Example, I have many countries list in which drilling down by country gives my its
java i18n struts
java i18n struts  hi i have a doubt ,i have developed i18n application with struts using dropdowns its working fine ,here if i select that dropdown list options like english ,its comming properly but in the dropdown list every
how to text send from list to textbox - Swing AWT
how to text send from list to textbox  dear sir/madam I whant to send text from list to textbox. plz give me solution for this problem.  ... the technology you have used like JSP/Servlet/Struts/JSF etc.. Thanks
Latest Version of Struts Framework
about Latest Version of Struts Framework. Here are the list of Struts Framework. The Latest Version of Struts Framework are on the top of this list...Complete detail and tutorials about the Latest Version of Struts Framework
Struts
Struts   How to retrive data from database by using Struts

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.