dcsimg
i want to fill list box using html:select
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ajay_Patel
Posted On:   Tuesday, April 10, 2007 04:54 AM

i want to fill list box using and then store the selected value to databsa. mydatabase table-test field-id,uname,city for that i create beans as follow: package demoBeans; /** * * @author Administrator */ import org.apache.struts.validator.*; import java.sql.*; import java.util.*; public class listBean extends ValidatorForm{ Connection cn=null; Statement st=null; ResultSet rs=null; ArrayList list=new ArrayList(); /** Creates a new instance of listBean */ public listBean() { } public ArrayList getList() { // String[] s=new String[100   More>>

i want to fill list box using and then store the selected value to databsa.

mydatabase
table-test
field-id,uname,city


for that i create beans as follow:


package demoBeans;

/**
*
* @author Administrator
*/
import org.apache.struts.validator.*;
import java.sql.*;
import java.util.*;

public class listBean extends ValidatorForm{

Connection cn=null;
Statement st=null;
ResultSet rs=null;
ArrayList list=new ArrayList();

/** Creates a new instance of listBean */
public listBean() { }

public ArrayList getList()
{

// String[] s=new String[100];
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
DriverManager.getConnection("jdbc:mysql://localhost/liaga","root","root");
st=cn.createStatement();
rs=st.executeQuery("SELECT * FROM TEST");
if(rs.next())
list.add("UNAME");

}catch(Exception e)
{

}
return list;
}



String uname=new String();
public String getUname()
{
return uname;
}

public void setUname(String username)
{
uname=username;
}

my action class as follow:
/*
* listAction.java
*
* Created on April 9, 2007, 10:09 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package demoAction;

/**
*
* @author Administrator
*/

import org.apache.struts.action.*;

import demoBeans.*;
import javax.servlet.http.*;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.struts.action.*;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class listAction extends Action{



public listAction() { }

public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
{
listBean listform= (listBean) form;

listform.getList();
return mapping.findForward("success");
}

}
and the struts.config as follow

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


"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">




























true : validate. DTD should be specified in file header (default)
false : no validation

Paths found in Tiles definitions are relative to the main context.
-->








property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>





now plz help me how use for to fill the value of uname and to store it in to database

   <<Less

Re: i want to fill list box using html:select

Posted By:   shree_bathina  
Posted On:   Tuesday, April 10, 2007 05:10 AM

i cant understand what u hv posted .please format it properly.
About | Sitemap | Contact