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



Home Answers Viewqa Struts dispalying arraylist values in table form
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shanta
dispalying arraylist values in table form
2 Answer(s)      a year and 11 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:
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
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
Advertisements
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
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
set the arraylist values - Struts
set the arraylist values   ResourceIdleReport.jsp <
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
disallow NULL values in a table.
disallow NULL values in a table.  How do I disallow NULL values in a table
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
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
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
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>
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
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
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
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
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
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
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
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
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  ... to insert all selected values in data base correspondent to each like if user selected india and then goa. I want to insert it to a table which has two fields
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
excel parsing and print data in the form of table
excel parsing and print data in the form of table  my reqment is i have to parse the excel and i need to print the data in the table by using swing jtable or else ....can u give the solution please
Inserting values in MySQL database table
Inserting values in MySQL database table   ... insert values in the MySQL database table. We know that tables store data in rows... the facility for inserting the values in MySQL database table. Description
Html form using JavaScript to display the table content
Html form using JavaScript to display the table content  HI There, Greetings, I am new to this java and I need your assistance. I have created the Java project that merges 2 xml file and produce the single xml. Then i
arraylist
arraylist   Using arraylist class , what type of exception are throws, how can write a java programe   An ArrayList can throw... ArraylistException { void buildAlphabet() { ArrayList list = new ArrayList
JSP textbox autopopulation on basis of SQL table values
JSP textbox autopopulation on basis of SQL table values  Hi, I need to achieve the following on J2EE platform Could you please help? The following table is created in MySQL DB: Problem type Status Responsible LEGAL
ArrayList
ArrayList  import java.util.*; class ArrayListDemo2 { public static void main(String args[]) { ArrayList al=new ArrayList(); al.add("one"); al.add("two"); al.add("three"); al.add("four"); for(int i=0;i Expected
 

 

 

DMCA.com