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



Home Answers Viewqa Struts want to insert values in drop down menu in struts1.3

Have Programming Question? Ask it here!
 
 
 


raj shah
want to insert values in drop down menu in struts1.3
0 Answer(s)      2 years and 4 months ago
Posted in : Struts


I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I have tried belowwith arraylist but was not able to find solution.

add.jspx

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : add
    Created on : Mar 4, 2012, 7:00:38 PM
    Author     : Administrator
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
          xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:html="http://struts.apache.org/tags-html"
          xmlns:fn="http://java.sun.com/jsp/jstl/functions"
          xmlns:bean="http://struts.apache.org/tags-bean" version="2.0">
    <jsp:directive.page  contentType="text/html" pageEncoding="UTF-8"/>
    <html:xhtml/>
    <html:html >
        <head>
            <title>
               <bean:message key="add.title"/>
             </title>
         </head>
        <body>
            <h1>  
                <bean:message key="global.heading"/>
                <jsp:text></jsp:text>
             <bean:message key="add.heading"/>
             </h1>
             <html:errors/>
             <html:form  action="/addSubmit">
                 <table class="addedit" >
                     <tr>
                         <td>
                             <bean:message key="pointForm.prompt.x"/>
                          </td>
                          <td><html:text name="pointForm" property="x"/></td>
                      </tr>
                      <tr>
                          <td>
                             <bean:message key="pointForm.prompt.y"/>
                          </td>
                          <td><html:text name="pointForm" property="y"/></td>
                      </tr>
                      <tr>
                          <td>
                              <bean:message key="pointForm.prompt.color"/>
                           </td>
                            <td>
                            <html:select property="color">
                                <html:options   property="colors"  />
                            </html:select>
                            </td>
                         </tr>
                         <tr>
                           <td>
                               <html:submit>
                                   <bean:message  key="pointForm.add.submit"/>
                               </html:submit>
                           </td>
                         </tr>

                    </table>
            </html:form>

        </body>
    </html:html>
</jsp:root>

struts-config.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">


<struts-config>
    <form-beans>
     <form-bean  name="pointForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property  type="int"
    name="id"  initial="-1"/>
    <form-property  type="double"
    name="x"  initial="0"/>
    <form-property  type="double"
    name="y"  initial="0"/>
    <form-property  type="java.lang.String"
    name="color"  />
    <form-property  type="java.util.ArrayList"
    name="colors"  />
    </form-bean>
    </form-beans>

    <global-exceptions>

    </global-exceptions>

    <global-forwards >

    </global-forwards>

    <action-mappings>
       <action name="pointForm" path="/add" scope="request" type="com.myapp.sruts.NewAction" validate="false">
       <forward name="success" path="/WEB-INF/add.jspx"/>
       </action>
       <action path="/addSubmit" name="pointForm" scope="request" inpu="/add.do" type="com.myapp.struts.AddAction"/>
    </action-mappings>

    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

    <message-resources parameter="com/myapp/struts/messages"/>

    <!-- ========================= Tiles plugin ===============================-->
    <!--
    This plugin initialize Tiles definition factory. This later can takes some
    parameters explained here after. The plugin first read parameters from
    web.xml, thenoverload them with parameters defined here. All parameters
    are optional.
    The plugin should be declared in each struts-config file.
    - definitions-config: (optional)
    Specify configuration file names. There can be several comma
    separated file names (default: ?? )
    - moduleAware: (optional - struts1.1)
    Specify if the Tiles definition factory is module aware. If true
    (default), there will be one factory for each Struts module.
    If false, there will be one common factory for all module. In this
    later case, it is still needed to declare one plugin per module.
    The factory will be initialized with parameters found in the first
    initialized plugin (generally the one associated with the default
    module).
    true : One factory per module. (default)
    false : one single shared factory for all modules
    - definitions-parser-validate: (optional)
    Specify if xml parser should validate the Tiles configuration file.
    true : validate. DTD should be specified in file header (default)
    false : no validation

    Paths found in Tiles definitions are relative to the main context.
    -->
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />      
        <set-property property="moduleAware" value="true" />
    </plug-in>

    <!-- ========================= Validator plugin ================================= -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property
            property="pathnames"
            value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>

</struts-config>

NewAction.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
import java.util.HashMap;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.util.ArrayList;
/**
 *
 * @author Administrator
 */
public class NewAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DynaValidatorForm pointForm = (DynaValidatorForm) form;
        ArrayList colorList = new ArrayList();

        return mapping.findForward(SUCCESS);
    }
}

messages.properties

global.heading=Points:
global.title=Points:
add.heading=Add
add.title=Add
add.submit=Add Point
pointForm.prompt.x=X:
pointForm.prompt.y=Y:
pointForm.prompt.color=Color:
pointForm.add.submit=add

AddAction.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts;

import org.apache.commons.beanutils.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;

/**
 *
 * @author Administrator
 */
public class AddAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";


    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DynaValidatorForm pointForm= (DynaValidatorForm) form;
       String x1=pointForm.get("x").toString();
        double x=Double.parseDouble(BeanUtils.getProperty(pointForm,"x"));
        double y=Double.parseDouble(BeanUtils.getProperty(pointForm,"y"));
        String color=(BeanUtils.getProperty(pointForm,"color"));
        System.out.println("x is "+ x1);
        return mapping.findForward(SUCCESS);
    }
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
want to insert values in drop down menu in struts1.3
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 have tried belowwith arraylist but was not able to find solution. add.jspx
drop down menu
drop down menu  drop down menu using html
Advertisements
Drop down menu
Drop down menu  I have created a drop down list of links which links to a table but if i click the link the table display in the other page i want to display it in the same page.Please tell me the solution
Add values of drop down menu( select option) to mysql table
Add values of drop down menu( select option) to mysql table   Here is my code <?php echo $row['valveName'].'<td>'.$row['valveId'].'<td>'; echo '<select name="onoff">'; echo '<
Drop down menu
Drop down menu  I have drop down list of some 14 links which links to the table,If i click each link the table should display below the link and again if i click the link the table should not appear. please help me
JSP Dependent Drop Down Menu
JSP Dependent Drop Down Menu  Hey Guy/Gals! I need someone help to guide me in creating a drop down menu, where the first menu affects the second menu and it's selection. So in my database I have a category table that has a ID
html menu button drop down
html menu button drop down  How to create a menu button in HTML?   <select id="category"> <option value="1">One</option> <option value="2">Two</option> </select> <select id
Get values in drop down list
Get values in drop down list  Pls provide me jsp code to get values in drop down list from another table's field. my project has customer... in drop down box in front end..... pls provide me code.. thanx
jQuery Drop Down Menu
jQuery Drop Down Menu       In this JQuery tutorial we will develop a program  to make Drop Down menu Steps to develop the Drop Down menu . Step 1:         Create
creation of drop down menu using ajax in java - Ajax
creation of drop down menu using ajax in java  Hi, Here I want to create a drop down menu using ajax in ofbiz framework. I want to fetch the data from database.I got examples using asp.net and php but I am not getting
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
jQuery Simple Drop Down Menu
jQuery Simple Drop Down Menu In this section, you will learn how to develop a simple drop down menu using jQuery. To develop a drop down menu we put... color="green"> Hover mouse on any menu item to drop down
how to import values from database to the drop down box
how to import values from database to the drop down box   hi iam... employee page i kept a drop down box for employee Ids i want all employee IDs will display in the drop down box please help me with the code
How do i retain values in the drop down - Struts
How do i retain values in the drop down  Hi, I have a jsp page... with the drop down. My problem is whenever i do this the values in the drop down gets reset while the others in the text boxes don't. How do i retain the values
How to send the data selected from drop down menu from html page to sql 2005 database.
How to send the data selected from drop down menu from html page to sql 2005 database.  Dear Sir, If I want to save the information provided by user from html drop down menu such as check-in date for hotel reservation
Drop Down
Drop Down  How to insert date into database using dropdown like facebook
How to insert multiple drop down list data in single column in sql database using servlet
How to insert multiple drop down list data in single column in sql database using servlet  i want to insert date of birth of user by using separate drop down list box for year,month and day into dateofbirth column in sql server
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc...) {*/ //String sql="insert into form1a values
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc...) {*/ //String sql="insert into form1a values
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc...) {*/ //String sql="insert into form1a values
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc...) {*/ //String sql="insert into form1a values
drop down
drop down  how can i add data from choice/dropdown component of java awt to myaql table
Pls provide me jsp code to get values in drop down list from another table's field....
Pls provide me jsp code to get values in drop down list from another table's... in customer registration page and should be shown in drop down box in front end... pages..... when i insert data in company registration .. it ll have company id
Drop Down Box
Drop Down Box  In a Drop Down box I want to show the user All the Country In the World. And when he type A-z,then each of the type Show those country which start with those word. Like I For-India
validation for drop down list
validation for drop down list  Hi all I have a form, it contain 12 drop down list. Each drop down has 1 to 5 values,i need to validate this form. the following condition should be true. 1.you can choose only 3 times 5 value. 2
drop down list in Struts
drop down list in Struts  How to create a drop down list in Struts
dynamic drop down list
dynamic drop down list  I want to create 2 drop down list, where it takes value from database and the two list are dependent..means if I select... on the value chosen from the previous. want code in javascript and jsp, Can you help
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.  The code for retrieving data from database into Drop Down List. <% DataSource data = new
drop down php mysql - PHP
drop down php mysql  PHP Script required to show the similar drop down item in each menu without refreshing the page. Is it possible if yes how
Drop Down reload in IE
Drop Down reload in IE  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down ( which is date) automatically
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute... is displaying.. i need code in java so that it takes multiple values
Ajax drop down and textbox
Ajax drop down and textbox  hie frnds I have a dropdown menu in the 3... menu consisting of options 1,2,3. When the user select any option from...;And one more thing how to insert to the database dynamically
Dynamic Dropdown Menu
records from your database in a drop down menu/list box. You can apply... a table in your desired database,  you can create and insert values using... values like this: insert into car_list values(0, 'aston martin'); and so on. Note
Login With Drop Down
Login With Drop Down   Hi all, I am doing a project using JSP. My... a drop down list consisting of Customs and Accounts. I have user accounts of both the departments. Now, my intention is to select the department from the drop down
dynamic drop down
dynamic drop down   I have created 2 drop downs in jsp.1 for department and other for its related designation.that means if I select a department... into the designation drop down (use jsp+javascript+servlet) reply soon   1
Drop down combos
Drop down combos  Hi.. How to write a javascript for linked combo dropdown boxes.   <html> <h2>ComboBox</h2> <script language="javascript"> var arr = new Array(); arr[0] = new Array("-select
Dependent drop down list
Dependent drop down list  hi,i am trying to design a form on which 2 dependent drop down list is used my code is successful but when i select class from first drop down list all the data get lossed means the value entered
drop down box - JSP-Servlet
drop down box  when i enter some letter in the input box,the corresponding words of that particular letter must be displayed below as a list from the data base in the same input box as drop down. Thanks&Regards, VijayaBabu.M
Excel Cell Drop Down List
Excel Cell Drop Down List In this section, you will learn how to validate data entered in a cell and provide a drop down list of possible values to the user... into cell A1 is restricted to the following : 10,20,30. The drop down is also
Drop down for search textbox like google search
Drop down for search textbox like google search  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop down list appear, then we can select one of word as our
Dependant & dynamic drop down list
on the values selected by user in first drop down list. How to achieve this ?   ...Dependant & dynamic drop down list  I don't know this should be in this or AJAX forum. I have one dynamic drop down list from data base (working
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated dynamically   Hi Friend, Create table country(country_id,country... want the code in ajax then try the following code: 1)country.jsp: <%@page
Drop down list from database
Drop down list from database  Hi, Can I know how do we get the drop down list from database? Eg: select country--select state--select district--so on.   1)country.jsp: <%@page import="java.sql.*"%> <html>
dynamic creation of multiple drop-down menus
dynamic creation of multiple drop-down menus  can anybody plz help me in coding for dynamic creation of multiple drop-down menus in a webpage using ajax/js/html/css
Drop-down text selection in jsp/html
. Now the first dropdown will have all the values. The second drop-down depends upon...Drop-down text selection in jsp/html  Hi, I am trying to create JSP... such dynamic dropdowns. Also based on the values selected in the drop-downs, I should
Drop Down Reloads again in IE..How to prevent this?
Drop Down Reloads again in IE..How to prevent this?  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down
Login With Drop Down, Having Departments in different table
field.Now want to login to the page by selecting the drop down box. Suppose...Login With Drop Down, Having Departments in different table  Hi all... the HTML page in such a way the I have a drop down list consisting of Customs
jsp drop down without refresh - JSP-Servlet
jsp drop down without refresh  Sir I have tried two depenedent jsp dropdown in jsp page,But the probleam is when i select first drop down its... jsp same probleam also arise. Please tell me how to use the drop down without
how to retreive data dynamically from mysql to drop down list
how to retreive data dynamically from mysql to drop down list   sir, i created a table in mysql and i inserted some values into the table through... the data of a particular column in a table into drop down list dynamically
view data from database using drop down list
view data from database using drop down list  hi i want to view the data from database by selecting a value in a drop down list. for an example drop down list have picture element.when click it select pictures from the database
Advertisements
 

 

 

DMCA.com