Home Answers Viewqa Struts dispalying arraylist values in table form

 
 


shanta
dispalying arraylist values in table form
1 Answer(s)      6 months and 4 days ago
Posted in : Struts

My result is in arraylist and i want to display it in table form using iterator tag

View Answers

November 16, 2012 at 11:13 AM


Struts 2 Iterator tag is used to iterate over a value, which can be any of java.util.Collection or java.util.Iterator.

1)IteratorAction.java:

package com.roseindia.common.action
import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class IteratorAction extends ActionSupport{

    private List<String> comboMeals;

    public List<String> getComboMeals() {
        return comboMeals;
    }

    public void setComboMeals(List<String> comboMeals) {
        this.comboMeals = comboMeals;
    }

    public String execute() {

        comboMeals = new ArrayList<String>();
        comboMeals.add("Snack Plate");
        comboMeals.add("Dinner Plate");
        comboMeals.add("Colonel Chicken Rice Combo");
        comboMeals.add("Colonel Burger");
        comboMeals.add("O.R. Fillet Burger");
        comboMeals.add("Zinger Burger");

        return SUCCESS;
    }
}

2)iterator.jsp:

<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
</head>

<body>
<h1>Struts 2 Iterator tag example</h1>

<h3>Simple Iterator</h3>
<ol>
<s:iterator value="comboMeals">
  <li><s:property /></li>
</s:iterator>
</ol>

<h3>Iterator with IteratorStatus</h3>
<table>
<s:iterator value="comboMeals" status="comboMealsStatus">
  <tr>
    <s:if test="#comboMealsStatus.even == true">
      <td style="background: #CCCCCC"><s:property/></td>
    </s:if>
    <s:elseif test="#comboMealsStatus.first == true">
      <td><s:property/> (This is first value) </td>
    </s:elseif>
    <s:else>
      <td><s:property/></td>
    </s:else>
  </tr>
</s:iterator>
</table>

</body>
</html>

3)struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <constant name="struts.devMode" value="true" />

    <package name="default" namespace="/" extends="struts-default">

        <action name="iteratorAction" 
            class="com.roseindia.common.action.IteratorAction" >
            <result name="success">pages/iterator.jsp</result>
        </action>

    </package>

</struts>









Related Pages:
dispalying arraylist values in table form
dispalying arraylist values in table form  My result is in arraylist and i want to display it in table form using iterator tag
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file... of the ArrayList in jsp in a tabular form/way. if (request.getParameter("action
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file... of the ArrayList in jsp in a tabular form/way. if (request.getParameter("action
Arraylist from row values
Arraylist from row values  Hello, can anyone please help on how to make an arraylist from the row values of a particular column from a database table? Thanks in advance!   import java.sql.*; import java.util.ArrayList
How to update table column from the values of Arraylist in java
How to update table column from the values of Arraylist in java  Hii Sir, I have an arraylist containing these values [2, 1, 1, 1, 1, 1, 1... As per my need i have to add these values into different fields of single
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets... to be filled. after filling the form the servlet generates a receipt and the values should... table ,but my program is working till generation of receipt and the values
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
Radio button with values from a String ArrayList in JSP?
Radio button with values from a String ArrayList in JSP?  Radio button values in JSP ArrayList<String> cs = CourseAssignments.getInstance...;table border="1" cellspacing="1" cellpadding="8" bgcolor= #EBDDE2>
Printing Values of Resultset to Html Table
need to collect the resultset values into the arraylist into a table. arraylist also contains timestamp values. Please help me in this regards Thanks in advance   JSP Display values of ResultSet to HTML table: <%@page
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain... in the html form is > 0 //found_list = StudentsManager.getInstance().studByYearÃ
arrayList
arrayList  how do i print a single index have multiple values String dist = "select distcode,distname from iwmpdistrict where stcode=29" ps = con.prepareStatement(dist
Jsp-delete checked checkboxes and display UNCHECKED checkboxes in table as well as in store that unchecked checkboxes in ARRAYLIST
values from the table. Use form tag and checkbox input. In in each checkbox... think you want to show the records of a table in a form and the checked records... table. Use submit or button to post the form information to page. Check for which
set the arraylist values - Struts
set the arraylist values   ResourceIdleReport.jsp <
JSP Arraylist Index
and value to the postindex.jsp, which take all values and placed into the ArrayList...Description: ArrayList is a class and a member of Java Collection Framework.... Code for JSP Arraylist index.jsp & postindex.jsp: index.jsp <%@page
How to Display values from databse into table
How to Display values from databse into table  I want to display values from database into table based on condition in query, how to display... enter either bookname or authorname and click on search button the values from
maximum size of arraylist - java
maximum size of arraylist - java  1.what is the maximum size of arraylist? 2.what is the drawback of arralist? 2.what is the drawback of JDBC... on size of RAM. The theoretical maximum number of elements in an ArrayList is 2
disallow NULL values in a table.
disallow NULL values in a table.  How do I disallow NULL values in a table
ArrayList
Java Notes: ArrayList java.util.ArrayList allows for expandable arrays, and is the Collections replacement for the older Vector class. An ArrayList has the following advantages over an array: An ArrayList automatically expands
Retrive Values
Retrive Values  I want to retrive the values between the td by the id using the javascript.So please help me... html form like this <TABLE width="100%" bgColor=""> <TR> <TD ID="td1">Cell 1</TD>
Problem dispalying Country, City, State in JSP using Ajax in Struts Framework - JSP-Servlet
Problem dispalying Country, City, State in JSP using Ajax in Struts Framework  Hi, In my JSP page, I have used one div that adds some rows... values. On the baisi of country selected, its corresponding state should come nd
ArrayList
Java Notes: ArrayList java.util.ArrayList allows for expandable arrays, and is the Collections replacement for the older Vector class. An ArrayList has the following advantages over an array: An ArrayList automatically expands
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table ... values in to an jsp file with additional values to store those values in to an database table. Please help me...... looking forward to hear from you
Hiding form values using ajax
Hiding form values using ajax  i am trying to show and hide form values with ajax but it's not working,but in javascript it is working.Can anyone will help me to the work in ajax please. Thanks in advance
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
vector and arraylist
vector and arraylist    suppose i have class A { public static arrylist a1(){} class B{ public static vector b1() {} } my question is how to class B method in Class A and how to get vector object values in class A without
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... can pass values by the two ways:    First, if we have to only pass
Form unable to hold values - Struts
Form unable to hold values  I have a form with a combo box having hasmap property. When i submit the search button and in event of an error, it does not bring the value only for this drop down box? Any ideas
getting error while inserting values in database
getting error while inserting values in database  AddUser.java...(); ArrayList al=null; ArrayList userList =new ArrayList(); String query = "insert
want to insert values in drop down menu in struts1.3
pointForm = (DynaValidatorForm) form; ArrayList colorList = new ArrayList...want to insert values in drop down menu in struts1.3  I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I
Problem with arraylist
, 0.0911138412309322] Match is true The values of cluster1outputrecord
how to validate all form field values at once.
how to validate all form field values at once.  how to validate all form field values at once. condition:no form field shold contain sometext("--select
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean
JSP - Checkbox remain checked although checked values should depend on values... to be on each page(shop1, shop2 and shop3) if the arraylist contains them of course before making a fresh new add, since adding is appending to the arraylist
Need to retain the values on submiting the form - XML
Need to retain the values on submiting the form  I have created the form using XML and XSL, with textbox,checkbox,textarea and two button submit and RESET. how to retain the values in the same page on clicking submit
ma access reading values
(table in my ms access) need to display values in jsp .............please help me... in register(table in my ms access) need to display values in jsp .............please... values throught servlet and register.jsp now i need code for reading values from
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi...(document.listsform)"> <FORM NAME="listsform"> <SELECT NAME="list1" onChange="setList(form)"> <OPTION>Fruit <OPTION>Vegetables
Check duplicate values and the count in an arraylist and store it in another list
Check duplicate values and the count in an arraylist and store it in another list  Hi All, I have a list which has four fields: year name, month... and the total of search string in that month and put that values in a new list. Please help
insert values - JSP-Servlet
insert values  How to insert values in the oracle database using JSP...;/head><body><table border="1" width="50%"...;/center></h1> <form method="POST" action="
ma access reading values
; <table align="right" valign="bottom" border="0" width="70" height="70" cellpadding="15" cellspacing="10"> <td> <form name="groovyform">...,this.name)"> </form> </td> </table> <table align="right
passing the form values with image upload - JSP-Servlet
passing the form values with image upload  Hii . I want to get the solution for passing values with an image uploading form. I cant access the request values from the fields rather than image . I want to know how can cut
JSTL : Submit Form TextField
can retrieve multiple values from the form.  Firstly we have to make one jsp page which contains a form in which we will enter the values. On submission...: <table border="1"> <form method="POST" action
Java ArrayList Example
and get() method fetch the string values from the arraylist...Java ArrayList Example  How can we use array list in java program..."); array.add("Arun"); System.out.println("ArrayList Size
Remove duplicates from ArrayList
Remove duplicates from ArrayList Sometimes we added large amount of data to ArrayList  where some values will get added twice or thrice which may... the Set back to the ArrayList. Here is the code: import java.util.*; public
Printing ArrayList - JSP-Servlet
(request,response); to print the values in ArrayList total, I did this in my JSP...Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total
ArrayList - JSP-Interview Questions
ArrayList(); %> Its not printing the values. do i need to do any...ArrayList  i used arraylist in servlet as shown ArrayList total = new ArrayList (); ... total.add(k[i]); session.setAttribute("efg",total
ArrayList<E>
class. An ArrayList has these characteristics: An ArrayList automatically expands as data is added. Access to any element of an ArrayList is O(1). Insertions and deletions are O(N). An ArrayList has methods for inserting, deleting
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where...; <form method="post" name="form"> <table border="1"> <tr><... to display all the select values from MySQL DB** only first value is displayed
inserting all the values in a html table column
inserting all the values in a html table column  strong text hai everyone, i'm a fresher to servlet i need to know that, how can i insert all the values in a html table column into a database. Thanks in advance

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.