wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP & JavaScript! assigning values to html form through Session variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP & JavaScript! assigning values to html form through Session variable" Watch "JSP & JavaScript! assigning values to html form through Session variable" New topic
Author

JSP & JavaScript! assigning values to html form through Session variable

Gul Khan
Ranch Hand

Joined: Sep 03, 2003
Posts: 173
Hi I have a scenario where i have to put objects in session or request and assign the values to the input form fields if the object is not null: here is what is happeneing.
I have a master and detail form. The user inputs some information and and adds more information on the detail form linked to the master form, after input of detail the user comes back to the master form and submits the form.
What i want is that to store both the forms data into an object (formData bean) and when the user comes to master-form after choosing the details, the fields(onload) should be filled with the data user keyed earlier and not empty. here is my JSP code and Javascript function.
<%formData=(FormData)session.getAttribute("formFields");%>
function onPageLoad(){
if("<%=formData%>"!="null"){
/// until here it works fine but than if its not null means the form is not new and there are values to bre retrieved from FormData Object.
var IdNo= "<%formData.getIdNo()%>";
// this is a method in FormData bean which returns the ID field value entered earlier. Now at this point it throws NullPointerException.
}
}
The first time when the jsp is loaded the formdata is null there obviously the method cannot be retrived which i m doing there so that i think is not the right way to do it.
Can someone plz help me out on how to populate the form fields from an object stored in session or request.
Thanks and regards
Gul
Gul Khan
Ranch Hand

Joined: Sep 03, 2003
Posts: 173
I managed to do it by declaring all the variables for form fields than retrieving the data in jsp and using those variables in the javascript.
is there a way to do it without declaring so many variables in jsp??
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP & JavaScript! assigning values to html form through Session variable
 
Similar Threads
saving the details in when i click next and previous buttons
HELP! JSP doesn't SAVE VALUES to BEAN
URGENT Help Needed ...!!
How to update Session variable with Form Data ?
File Upload