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



Home Answers Viewqa Ajax getting null value in action from ajax call
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


BHARAT GUPTA
getting null value in action from ajax call
0 Answer(s)      2 years and 5 months ago
Posted in : Ajax


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;
    }

Advertisement
View Answers

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 null value in my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload  getting null value in my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload  getting null value in my class when using t:inputFileUpload i have implemented all... changes in web.xml also still getting null value when i access in my bean Thanking
database call from javaScript - Ajax
database call from javaScript  Dear All, In my project i have one... name. and i have to do this in javascript.How do i call database query ,if suppose i have selected two building from text area,i have to finish
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
https call in AJAX - Ajax
https call in AJAX  Hi, I am trying to call a https URL in my AJAX script which is in my JSP. But it is not getting the reponse from the url i.../jsp/popup-window-using-ajax-in-jsp.shtml Hope that it will be helpful for you
getting unique value from java.util.random - Java Beginners
getting unique value from java.util.random  i am doing a shopping... for that i used java.util.random to get random productid from product table, but the value which i am getting contains duplicate values and it is not unique, my
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 pass value from dijit.Tree to dijit.MenuItem - Ajax
How to pass value from dijit.Tree to dijit.MenuItem  Hi Friends, I... of 'Test' I want to show the value of that Node( which is comming from TreeNode... node whicl will apper on right click. What I have already done. From my server
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
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
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
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.
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
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
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
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
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
Getting garbage value
Getting garbage value  Thank You Sir for helping me out from... from the link gets some garbage value whenever I'm using some particular set of value like from 0010 to 0757. After that from 0758 to 2400 every value returns
Getting garbage value
Getting garbage value  Thank You Sir for helping me out from... from the link gets some garbage value whenever I'm using some particular set of value like from 0010 to 0757. After that from 0758 to 2400 every value returns
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
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 garbage value
Getting garbage value  Thanks for the reply. Its works well, but whenever I'm using numeric value from 0010 to 0757 it is returning some garbage value. I dont have the idea what is going wrong. Please give me some idea to solve
<%=request.getHeader("referer")%>,getting null in jsp - JSP-Servlet
,getting null in jsp  Hi, I am getting null in in jsp.Could you help on this regards. Thanks Ajay   Hi friend, Code to help in solving the problem : Thanks
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
Java-call by value - Java Beginners
Java-call by value  Why java is called strictly "call by value" and not "call by reference" ?Please explain with example?  Hi Friend... object references by value. This is because two copies of the same reference refer
Advertisements
 

 

 

DMCA.com