getting null value in action from ajax call

Ads
 

getting null value in action from ajax call

Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need help, i am new to struts2 and hibernate.

StudentRegistration.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>

<html>
<head>
    <sx:head />
    <title>Student Registration</title>
</head>

<script>
function show_details() {
dojo.event.topic.publish("show_detail");
}
</script>

<body>
    <s:form id="form1" name="form1" action="StudentRegister" method="post" enctype="multipart/form-data" theme="simple">
    <s:hidden name="id" />
    <table border="0">
    ...

    <tr>
    <td><s:label value="Course " for="course" /></td>

    <td><s:select name="course" list="courseList" onchange="javascript:show_details();return false;" /></td>
    </tr>
    <tr>
    <td colspan="2"><s:url id="durl" action="secload" /><sx:div showLoadingText="" id="details" href="%{durl}" listenTopics="show_detail"  formId="form1" ></sx:div></td>  
    </tr>

    <tr>
    <td align="center" colspan="2"><s:submit /></td>
    </tr>
    </table>
    </s:form>
</body>
</html>

Detail.jsp

<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<table border="0" width=100%>
<s:if test="branchList != null">
<tr><td><s:select name="branch" list="branchList" label="Branch"></s:select></td></tr></s:if>
<s:if test="semList != null">  
<tr><td><s:select name="sem" list="semList" label="Semester" /></td></tr></s:if>
</table>

FirstList.java

package bharat;

    public class FirstList extends ActionSupport {
        private String course;
        private Map<Integer,Integer> semList=null;
        private Map<String, String> branchList=null;

        public String execute() throws Exception
        {
            populateTwo(getCourse());
            return SUCCESS;
        }

        public void populateTwo(String id1)
        {
                    // Get null value for id1
            System.out.println (id1);

            if(id1!=null&&!id1.equals(""))
            {
            semList=new HashMap<Integer,Integer>();
            branchList=new HashMap<String,String>();
            if (id1.equalsIgnoreCase("B.Tech.")||id1.equalsIgnoreCase("M.Tech.")) {  
                branchList.put("CSE","CSE");
                branchList.put("ECE","ECE");
                branchList.put("MAE","MAE");
                branchList.put("CHE","CHE");
                branchList.put("CVE","CVE");
                branchList.put("IT","IT");
                } else if (id1.equalsIgnoreCase("MCA")) {  
                    branchList.put("CS","CS");
                    branchList.put("EC","EC");
                    branchList.put("MA","MA");
                    branchList.put("CIV","CIV");
                    branchList.put("IT","IT");
                }
                else{branchList.put("None","None");}
            if (id1.equalsIgnoreCase("B.Tech.")||id1.equalsIgnoreCase("Bio.Tech.")) {  
            semList.put(1,1);  
            semList.put(2,2);  
            semList.put(3,3);  
            semList.put(4,4);  
            semList.put(5,5);
            semList.put(6,6);
            semList.put(7,7);
            semList.put(8,8);
            setSemList(semList);
            } else if (id1.equalsIgnoreCase("M.Tech.")) {  
                semList.put(1,1);  
                semList.put(2,2);  
                semList.put(3,3);  
                semList.put(4,4);
            } else {  
                semList.put(1,1);  
                semList.put(2,2);  
                semList.put(3,3);  
                semList.put(4,4);  
                semList.put(5,5);
                semList.put(6,6);
            }
            }
        }

        public String getCourse() {
            return course;
        }
        public void setCourse(String course) {
            this.course = course;
        }
        public Map<Integer,Integer> getSemList() {
            return (this.semList); 
        }
        public void setSemList(Map<Integer,Integer> semList) {
            this.semList = semList; 
        }
        public void setBranchList(Map<String, String> branchList) {
            this.branchList = branchList;
        }

        public Map<String, String> getBranchList() {
            return branchList;
        }
    }

Struts.xml

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

<struts>
    <package name="default" extends="hibernate-default">
    ...
    <action name="StudentRegister" class="bharat.RegistrationAction">
          <interceptor-ref name="defaultStackHibernate">
        <param name="fileUpload.allowedTypes">image/png,image/gif,image/jpeg</param>
        </interceptor-ref>
        <result name="input">/jsp/StudentRegistration.jsp</result>
        <result name="success">/jsp/success2.jsp</result>
    </action>
    **<action name="linkStudentRegister" method="populateOne" class="bharat.RegistrationAction">
        <result name="success">/jsp/StudentRegistration.jsp</result>
    </action>
    <action name="secload" class="bharat.FirstList">
        <result name="success">/jsp/Detail.jsp</result>
    </action>**
    </package>
</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>CourseRegistrationModule</display-name>
  <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

RegistrationAction.java

package bharat;

public class RegistrationAction extends ActionSupport implements ModelDriven<Register>,ServletRequestAware {

    private Register register = new Register();
    private RegisterDAO registerDAO = new RegisterDAOImpl();
    private HttpServletRequest servletRequest;
    private Map<String,String> courseList= null;

    public String populateOne()
    {
        System.out.println ("populateone");
        courseList=new HashMap<String,String>();
        courseList.put("B.Tech.","B.Tech.");
        courseList.put("M.Tech.","M.Tech.");
        courseList.put("MCA","MCA");
        courseList.put("Bio.Tech.","Bio.Tech.");
        return SUCCESS;
    }


    public Map<String,String> getCourseList() {
        return (this.courseList); 
    }
    public void setCourseList(Map<String,String> courseList) {
        this.courseList = courseList; 
    }

    @Override
    public Register getModel() {
        //TODO
        return register;
    }
View Answers

Ads









Related Tutorials/Questions & Answers:
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need..." name="form1" action="StudentRegister" method="post" enctype="multipart/form-data
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need..." name="form1" action="StudentRegister" method="post" enctype="multipart/form-data
Advertisements
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need..." name="form1" action="StudentRegister" method="post" enctype="multipart/form-data
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
what is an ajax call?
what is an ajax call?  can u please explain the correct usage of an ajax call in jsps and java script.   hi friend, Ajax is new technologies for the development of web application. Ajax is known as Asynchronous
How to get more than one value from ajax
How to get more than one value from ajax  I have multiple select list box in php. i filled the value using ajax. how to get different value to fill the same list box Ex. option value as id option name as some string
Why you are not getting value from your data science?
Why you are not getting value from your data science?  Hi, I am... for the tutorials to learn: Why you are not getting value from your data science? Try...;Why you are not getting value from your data science?". Also tell me which
what is an ajax call?
what is an ajax call?  can u please explain the correct usage of an ajax call in jsps and java script
Nested Ajax--not getting output
Nested Ajax--not getting output  Hi everyone... I have two.jsp page from that , with the help of ajax i have called three.jsp. So, i have used DIV... time running...when i run One.jsp , with the help of ajax when i call two.jsp.
ajax+options is null or not an Object
ajax+options is null or not an Object  HI i have developed a simple ajax application contains two drop down lists and and one search button when i seleted a mangername from the popuated dropdwon list its dispalyed all
javascript call action class method instruts
javascript call action class method instruts  in struts2 onchange event call a method in Actionclass with selected value as parameter how can i do
Output of null value
main(String [] args){ String str=null; System.out.println(str); } } Output value Null Description:- In the given example... a String variable and initialized it with null value
getting db in action class
getting db in action class  hi, Am usin struts in ma application... n i need to interact with the db .. so i used.. getDataSource(request) but it gives me an error.. java.lang.NoSuchMethodError: LoginAction.getDataSource(Ljavax
mysql query for null value
mysql query for null value   What mysql query for null value i need... { //echo message } To check if the object contain any value or not ..just compare it with zero. If the value for object is greater than zero display
Error in checking null value in string
Error in checking null value in string  Error in checking null value in string Hi am getting Exception : java.lang.NullPointerException in the following code: String registerno=null; registerno=request.getParameter("registerno
Struts2.2.1 Action Tag Example
Struts2.2.1 Action Tag Example The Action tag  is used to call action class directly from a JSP page. We can call action directly by specifying... the results from the Action. The following Example will shows how to implement
getting values from dropdown list
getting values from dropdown list  I am having a dropdown list which... to the action. My action is getting called however, i am not sure how to pass the selected value to the action. Please can any one please help me out
Pass value of rasio button from jsp page to action class(not conventional problem)
Pass value of rasio button from jsp page to action class(not conventional...; </table> <s:submit value="Delete" action="deleteSchedule...;table border="1"> <tbody> <s:iterator value
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
Getting Null pointer Exception in the jsp page
Getting Null pointer Exception in the jsp page  I have developed this jsp page to store the data in database.While storing the value of check box in database I am getting null pointer exception in the following code
ModuleNotFoundError: No module named 'djangocms-call-to-action'
ModuleNotFoundError: No module named 'djangocms-call-to-action'  Hi...: No module named 'djangocms-call-to-action' How to remove the ModuleNotFoundError: No module named 'djangocms-call-to-action' error? Thanks  
RADIO FROM JSP TO ACTION.
RADIO FROM JSP TO ACTION.  Hi frds, how to get the selected multiple radio button values from jsp to action
write a program to demonstrate call by value and call by reference.(pass objects as parameters)
write a program to demonstrate call by value and call by reference.(pass objects as parameters)  write a program to demonstrate call by value and call by reference.(pass objects as parameters
radio button value on edit action
...Problem 'm facing is on edit action 'm not retrieving radio button value..i have...radio button value on edit action  This is my edit.jsp code...In my...; } } function toggle(value) { if(value
getting coords from an image.
getting coords from an image.  how to get coordinates dynamically(in run time) from an image?? pls help me
receiving null value in back bean by the jsf page
receiving null value in back bean by the jsf page  i have done above things but i m receiving null value in back bean by the jsf page plz tell me solution as soon as possible
getting files from VSS
getting files from VSS  I am not able to get the files from VSS.I am using following code. and just let me know is localpath attribute is for our local project path? I am getting the problem in this line failed
Call an array from multiple functions
Call an array from multiple functions  I am having two methods in this method i am getting array values from another class. i create same array name for accessing the method values(array) but it will access only one method values
ModuleNotFoundError: No module named 'default_value_for_each_call'
ModuleNotFoundError: No module named 'default_value_for_each_call'  ...: No module named 'default_value_for_each_call' How to remove the ModuleNotFoundError: No module named 'default_value_for_each_call' error? Thanks

Ads