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
<?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);
}
}
View Answers
Related Tutorials/Questions & Answers:
want to insert values in drop down menu in struts1.3want 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
Advertisements
Drop down menuDrop 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
Drop down menuDrop 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
Get values in drop down listGet
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
html menu button drop downhtml
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
JSP Dependent Drop Down MenuJSP 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
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 Drop Down Menu
jQuery
Drop Down Menu
In this JQuery tutorial we will develop a
program to make
Drop Down menuADS_TO_REPLACE_1
Steps to develop the
Drop Down menu .
Step 1:
ADS
creation of drop down menu using ajax in java - Ajaxcreation 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
How do i retain values in the drop down - StrutsHow 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 jQuery Simple Drop Down MenujQuery 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 Drop DownDrop Down How to
insert date into database using dropdown like facebook
drop downdrop down how can i add data from choice/dropdown component of java awt to myaql table
Drop Down BoxDrop 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 listvalidation 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
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..._TO_REPLACE_2
After that
insert few
values like this:
insert into car_list
values(0
dynamic drop down listdynamic
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
drop down php mysql - PHPdrop 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
Ajax drop down and textboxAjax
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
Drop Down reload in IEDrop 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
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 i want to update valuesi
want to update values in my form i have 2 submit buttons one for edit and another for update on page load all my details need to fetch from database and it need to
insert automatically in to disabled text boxs and once i press
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
Excel Cell Drop Down ListExcel 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
insert values - JSP-Servletinsert values How to
insert values in the oracle database using JSP...;
insert user_details
values('"+username+"','"+jobposition+"... page<html><head><title>
Insert value in database</title><
Drop down combosDrop 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 listDependent
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 for search textbox like google searchDrop 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
drop down box - JSP-Servletdrop 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
insert values from excel file into databaseinsert values from excel file into database hi i
want to
insert values from Excel file into database.Whatever field and contents are there in excel... the following link:
Insert values from excel file to database
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 Optionjsp
drop down-- select Option how to get
drop down populated dynamically
Hi Friend,
Create table country(country_id,country... Friend,
If you
want the code in ajax then try the following code:ADS
Drop down list from databaseDrop 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>