Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts dispalying arraylist values in table form

Have Programming Question? Ask it here!
 
 
 


shanta
dispalying arraylist values in table form
2 Answer(s)      a year and 9 months ago
Posted in : Struts


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


Advertisement
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>


August 21, 2014 at 1:01 PM


can we access the values obtained through s:property in jquery?



Related Tutorials/Questions & Answers:
set the arraylist values - Struts
set the arraylist values   ResourceIdleReport.jsp <
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
Advertisements
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
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
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
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I used your code for getting a values,i used the fllowing function submitForm(f){ var form = document.createElement("form"); with(form
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
form
form   Can I prevent a form from being submitted again
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 and vector
arraylist and vector  what is the diff b/w arraylist and vector
Java ArrayList
Java ArrayList   How to declare unique ArrayList
ArrayList and Vector
ArrayList and Vector  hello, Why ArrayList is faster than Vector?   hii, ArrayList is faster than Vector, because ArrayList is not synchronized. Synchronization will reduce the performance of Vector
Joining two table using Natural Left join
to the first table's field values  means a left outer join returns all the values from the left table and matched values from the right table (NULL in case...Join Table with Natural left join In Natural Left join, both table are merge
Java arraylist of arraylist
Java arrayList can make the use of other arrayList.  In one arrayList other arrayList can be added as the object  It works as two dimension array. Example of Java Arraylist of Arraylist import
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
HEAP table
HEAP table  hiii, What is HEAP table?   hello, This type of table is stored in the memory. Speed of execution of this table is very commendable
Java arraylist, linkedlist
Java arraylist, linkedlist  What is the major difference between LinkedList and ArrayList
Java arraylist index() Function
Java arrayList has index for each added element. This index starts from 0. arrayList values can be retrieved by the get(index) method. Example of Java Arraylist Index() Function import
center a table
center a table  How do I center a table
arraylist vs vector - Java Beginners
arraylist vs vector  hi, i want to know what is the difference between arraylist and vector in case of performance. in what cases we should go for arraylist and in what case we should go for vector. is there any   array
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
ArrayList in JSP
all  values and placed into the ArrayList object. Through Iterator all...ArrayList in JSP ArrayList is a class and a member of Java Collection...: Index Values
arraylist with session - JSP-Servlet
arraylist with session  hi how can an arraylist stored in session.. and also how will it access?? pls give me the details with sample code..   Hi friend, Code to solve the problem : Thanks
values in combobox - Java Beginners
values in combobox  how to fill values in combo box i.e. select tag in html using javascript?   Hi Friend, Try the following code... = combo1.value; document.forms["form"].elements["combo2"].options.length=0
@SessionAttributes multiple values
ArrayList(); //Add some values in list list.put("Something"); //Add...@SessionAttributes multiple values In this section we will see how you can use @sessionattributes to set multiple session values to it. While developing
ArrayList problem - JSP-Servlet
ArrayList problem  Hi, How can I add elements of an ArrayList to HTML combobox or list in java? Hi, You can use the following code: Array List..." name="MYLIST"> <% ArrayList a_list = new ArrayList
how to take input table name in jsp to create table in mysql?
how to take input table name in jsp to create table in mysql?  how to take input table name in jsp to create table in mysql?   Hello Friend, Try the following code: <%@page import="java.sql.*"%> <form method
arrayList - Java Beginners
must check through the desktop arraylist and notebook arraylist. How can I combine this two arraylist checking for throw out the msg of "Computer list is empty!" Currently I only can check for desktop arraylist empty if no desktop is added
JTable values are not gettiing properly
JTable values are not gettiing properly  Sir, I created one JTable with two columns and one row i have given two values,but i getting only one...*; public class sd25 extends JFrame implements ActionListener { //3 month table
updating a table in a database - SQL
updating a table in a database  give me complete source code in java to execute the sqlquery such that (update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
how to store a dynamic values - JSP-Servlet
and bonus is ~5 . Thanks Hr in another arraylist i have a values ~2,~3...how to store a dynamic values  Dear sir, i have a ArrayList in that i have stored a values from a excel sheet specified column values and i
Quotes around attribute values.
Quotes around attribute values.  Should I put quotes around attribute values
Extjs Table Sorting
Extjs Table Sorting  how is it possible to do the table sort in extjs
ArrayList - Java Beginners
"); //Vector vector=new Vector(); ArrayList arfray=new ArrayList...("Show All"); Vector vector=new Vector(); ArrayList arfray=new ArrayList
Java plateform dependent values
Java plateform dependent values  How will you get the platform dependent values like line separator, path separator, etc., ?  we will get the the platform dependent values like line separator, path separator
Java arraylist iterator
ArrayList has iterator() method.Using iterator() method  elements of the arraylist easily gets retrieved. iterator() can be used in the for loop. It is clear by the given example. Example of Java Arraylist
Java ArrayList sublist
It returns the part of the ArrayList as List reference. part is the given range between two indexes. Java Arraylist Sublist Example import...) { String  ar[]={"india","pakistan","United Kingdom","Japan","Korea"}; ArrayList
disable the form - JSP-Servlet
wrote jsp page in that 8 forms are there.all forms are same but the input values are different.when I click the form button,one function is calling and the input values(only one input value is going to servlet) are going to servlet class using
Java arraylist foreach
In the arraylist, foreach loop is easily used. It takes element... Example Java arraylist foreach import java.util.ArrayList; import...) {         List list=new ArrayList();         String names[]={"mac","john
retrive values - JSP-Servlet
retrive values  how to retrive multiple values from html to jsp  Hi Friend, Try the following code: 1)calljsp.html: Enter Name: Enter Address: Gender:MF Qualification: Btech MBA MCA MSC
Iterate java Arraylist
Iterator is an interface in the collection framework. ArrayList... of the ArrayList can be traversed by the Iterator. Iterator has methods hasNext() and next(). Example of Java Arraylist Iterate import java.util.*; public class
Data types in a table
Data types in a table  hii, What are the data types allowed in a table?   hello,, These are the data types in table:- VARCHAR2, CHAR... types in table:- VARCHAR2, CHAR, NUMBER, RAW, DATE, LONG and LONG RAW
Java ArrayList removeall
the elements from list1 which is present in the list2 Java Arraylist Removeall...","Korea"}; ArrayList list=new ArrayList(); ArrayList list1=new ArrayList
Table refresh with ajax - Ajax
Table refresh with ajax  I am using jsp/html in my code. Is it compulsory that i have to use a servlet to implement table refresh using ajax? Or jsp also would work? Rajatha
Java new arraylist
Java ArrayList object is created with the reference of List interface Object is also created directly by the ArrayList class Java New Arraylist..."}; //ArrayList list=new ArrayList(); List list=new ArrayList(); list.add(ar[0
Developing Forgot Password Form
Developing Forgot Password Form   ... Form code for our application. Developing Forgot Password Form   The forgot password form will be used, when user forgot their password. This form
Java arraylist for loop
Elements of the ArrayList can be easily added and retrieved by the for loop. Example FOR Java arraylist for loop import java.util.ArrayList...(String[] args) {         List list=new ArrayList();         String names
Java ArrayList clone
It returns the copy of the given ArrayList object as the Object class. So it must be casted to the ArrayList for further use. Java Arraylist...","Japan"}; ArrayList list=new ArrayList(); list.add(ar[0]); list.add(ar[1
passing values - JSP-Servlet
_DataInsertion(Name,Hallno,Time,Date,Mobileno,Status) values('"+name+"','"+hallno+"','"+time
Java arraylist merge
is joined in to the list1. Example Java Arraylist Merge import...};         List list1=new ArrayList();         List list2=new ArrayList
 

 

 

DMCA.com