======NewContact.jsp==============0
Here I'm getting the Model object and rendering happly.
======Users.java(Model Class)======1
package com.one.model;
import java.util.ArrayList;
public class Users
{
private ArrayList<String> al;
private String x;
private int y;
// getters and setters
}
===============UsersDao.java(Dao interface)========2
package com.one.dao;
import com.one.model.Users;
public interface UsersDao {
public Users getModified(Users glist);
}
}
==============UsersDaoImpl.java(Dao Implementation)=======3
package com.one.daoimpl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import com.one.dao.UsersDao;
import com.one.model.Users;
public class UsersDaoImpl implements UsersDao {
private JdbcTemplate jdbcTemplate;
public UsersDaoImpl(DataSource dataSource)
{
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
public Users getModified(Users glist)
{
String sql1 = "SELECT user_group FROM users";
//Here I was strucked.
return glist;
}
}
Here I was strucked. I have JdbcTemplate class obj. This is Spring MVC application. I'm able to executing other queries here,no problem. And displaying the all the values in the view pages no problem. But I need get drop down menu in NewContact.jsp. For that I'm creating Model object in Controller class and Sending that model object to the NewContact.jsp i.e view page. but how can I inject only user_group values from the databse table,assume "users"(is table) and "name,sal,user_group"(are the columns OF "users" table).
Finally, when I am returning an object(i.e object of the Model'Users.java') from the UsersDaoImpl class,only model object "ArrayList al" must be initialized. But x and y variables should not be initialized. I Don't want to use AJAX here.