I have a drop down in a jsp page having the following code
<s:select name="newQuestion.CertificationId"
list="certificationList"
listKey="certificationId"
listValue="certificationName"
headerKey=""
headerValue="Select Certification"
label="Certification Name"
onchange="getQuestionsList(this.value)" />
Now the on change event of the drop down is calling a JS function getQuestionsList() which intends to fetch the question list of the certification Id choosen.
In the JS function I am submitting it to a action class where I am doing a DB call to fetch question list based on values of certification Id
function getQuestionDetails(value){
var submiturl = "Action1.action?certId="+value;
$.ajax({
url:submiturl,
type: 'get',
beforeSend: function(){
$("#loading").show();
alert("parsed");
},
success: function(result){
if(result!=''){
} else {
alert(result);
}
},
});
}
Now in the action class I am setting the value of questionList with values I fetch from database .questionList is a instance variable in action class with getter and setter methods.Now in struts.xml I am passing to the same jsp where I had the drop down
<action name="questionAction" class="questionInfo.QuestionManager"
method="displaySelectedQuestions">
<result name="loaded">/questionAdmin.jsp</result>
</action>
The problem I encounter is when I go back to the jsp I am not able to retrieve the question List which I display in an iterator
<table class="registrationDetailsTable">
<tr class="tabledataheader">
<td>Question Id</td>
<td>Question Description</td>
</tr>
<s:iterator value="questionList">
<tr class="tabledatarow">
<td><s:property value="questionId" /></td>
<td><s:property value="questionDesc" /></td>
</tr>
</s:iterator>
</table>
Please let me know where I am getting wrong so that I have the question List populated in my jsp
When you call your action with
$.ajax(...), the action creates the response by forwarding to the view (questionAdmin.jsp), right? And this response should be available to you in that Ajax call’s return value handler.So when you have this:
You should do something with the resulting HTML. You could begin by doing just
alert(result)to see what you are getting and then display the new list contents using Javascript. I would do it so that you have a div containing your table like this:So now you can do this: