This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Bean qns  RSS feed

 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem which contains 3 fields : m1, m2 and result respectively. m1 and m2 are input fields. m3 is also an input field ,but the attribute is read only. Users have to input number into m1 and m2. In the OnChange status, it'll call a function to validate and calculate like m1 * m2 = result in javascript. e.g. input ... onChange=cal(this)..
As I don't want the logic exposure to users, how can I call a bean to do it?
Thanks
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only use the bean on the server after your form is submitted.
I doubt that onChange will exactly do what you intend. It doesn' t react untill one clicks somewhere else in the page. This only irritates users.
I'd rather make it clear that the submit button has to be clicked to proceed. "1. Step: fill out m1 and m2, then hit 'calculate'. 2. Step... "
cb
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Chris pointed out, you cannot mix client-side and server-side operations.
Remember that any Java in your JSP pages is executed on the server to format the HTML page to send to the browser. Once the browser has the page, all Java (including beans) is long gone and you must perform operations using client-side technology, or submit a new request to cause server-side processing to create a new page.
bear
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!