|
Hello,
got a big problem ...
We got a task we cant solve (Obviously, if we could i wouldnt ask here).
Unfortunately we are just allowed to use JavaScript, JSP and JSTL (and HTML of course, we are not allowed to write Java-Code into our HTML-Page.
Our task is:
A page with 2 Textfields and 1 Button.
You shall be able to enter nothing else than numbers in these Textfields (floats or ints, nevermind)
When you enter a value to the last Text Field, there should automatically appear a new Text Field under the others.
So that you can enter as many numbers as you want to.
The button shall sum these numbers.
BUT the sum shall be displayed on another page, and the sum itself shall be calculated on the first page and shall be saved in Beans class.
So, we made 2 pages and one bean.
Numbers.jsp, Sum.jsp and Add (this is the bean)
The Sum.jsp takes the bean and just displays the result.
Thats very easy ...
Our Numbers.jsp generates via JavaScript the new Text-Fields.
Our Problem is, we dont know how to write into the bean from dynamically generated textfields and without pressing a button, because the button shall redirect to Sum.jsp.
Right now we have a workaround ... we reload the page and take the "request.getParametersMap()" and write this into the bean.
But we dont like this idea very much ...
Can anyone help ?
Greetings,
Shera
|
|
|
|
|
So what you want is for us to do your homework for you. That isn't going to happen. You will learn nothing if someone else does this for you.
Make an effort. If you run into problems, post the code specific questions you have here and we'll be more than happy to help.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Well, no i dont want you to do my homework ...
We already spent hours on this task, but we dont find a way to solve it in a proper way.
We just want to know how to save from dynamic generated text fields into a bean.
As far as i know you can use "c:set" just in your HTML-Code.
And ... this doesnt work with autogenerated TextFields, because the JavaScript Code is executed on my WebBrowser(Client-Side) and the Server wont be able to save it into a Bean, because the server doesnt know about these "new" text fields that JavaScript generated.
Server just knows about them if we send a new request, but thats quite "dirty code"
I just want suggestions, if anyone has ...
|
|
|
|
|
I don't know much about Jave and beans, but based on what you said couldn't you put a hidden text field on your page, so your server side is aware of it. Then you can use JavaScript to sum the dynamic fields and store the summed value in the hidden text field and use cset to save the value to your bean.
|
|
|
|
|
Damn it ...
"Why simple, if there's a difficult way"
(German saying )
Thank you, thats a pretty easy way to solve this problem.
Seems as if we had thought too complicated.
|
|
|
|